Comments (3)
Hello sorry for the late reply.
this.biggerNum
is undefined because you're trying to access a getter from another getter.
Remember Vuex getters only have access to the state
object.
from vuex-class-component.
Hi @michaelolof,
It's no problem, thank you for the reply!
I'm not sure if that's right? I've had no problem using the normal vuex way of access getters within getters. The first argument is state, but then the second argument is generally the getters object. Within namespaced modules, the 3rd and 4th argument are rootState and rootGetters
You should be able to see what I mean here:
https://vuex.vuejs.org/guide/getters.html#property-style-access
const store = new Vuex.Store({
state: {
todos: [
{ id: 1, text: '...', done: true },
{ id: 2, text: '...', done: false }
]
},
getters: {
doneTodos: state => {
return state.todos.filter(todo => todo.done)
},
doneTodosCount: (state, getters) => {
return getters.doneTodos.length
}
}
})
https://vuex.vuejs.org/guide/modules.html#module-local-state
const moduleA = {
// ...
getters: {
sumWithRootCount (state, getters, rootState, rootGetters) {
return state.count + rootState.count
}
}
}
I hope this helps to explain what I mean, if this isn't a feature you're looking to implement then please let me know.
Thank you for you help!
from vuex-class-component.
We've also run into this problem. We make use of the 2nd getter param fairly extensively.
Any chance you'd consider (reopening this issue, and) fixing this or accepting a PR which adds support for it?
To a lesser extend we also use rootState and rootGetters, but we could probably live without that.
from vuex-class-component.
Related Issues (20)
- Mutation requires object reference to change
- Cannot write independent tests because of module cache HOT 1
- Vuex 5 support and breaking changes
- TypeError: commit is not a function HOT 1
- Change the namespace later to create an abstract store
- [Bug] Actions force you to be async HOT 2
- ProxyWatchers small declaration issue
- watch, $subscribe and $subscribeAction all return void instead of the unsubscribe function HOT 1
- [BUG] npm package Version 2.3.2 still has pr #64 related issues. HOT 2
- Has no exported createModule
- [BUG]Mutation in Action doesn't work sometimes. HOT 2
- Calling getter in mutation HOT 1
- [Feature] ApiValue and ApiAction for fetching remote resources into store HOT 1
- Built files in "/dist" not updated? HOT 1
- [Bug] Store broken in 2.3.4 HOT 3
- [Bug] SSR data not saved in store when using nuxt fetch hook HOT 3
- Feature Request: A Bind decorator for class components
- Example on how to use with Nuxt HOT 3
- Access plugin on Action HOT 7
- Vue3 compatible HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuex-class-component.