'Passing value to store getters Vue.js
I'm trying to pass ID as parameter to store getter, but when i console that id I get undefined. Can someone help me with this:
Here is my code:
This is how i call getter:
this.$store.getters['users/list']('users', '123')
This is getter function:
getters: {
list: (state, getters, rootState, rootGetters, userId) => (key) => {
console.log(userId)
}
}
Solution 1:[1]
You were pretty close:
new Vuex.Store({
getters: {
someMethod: (state) => (userid) => {
console.log(userid);
}
};
}
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | null |