Answer the question
In order to leave comments, you need to log in
How to call a function in a component after a property in the vuex store changes?
I have a datastore in vuex and two components.
The first component is a range slider where I change the slider values and immediately send them to the store.
The second is the component in which I need to call my function when the store changes .
my store
state: {
value: 0,
rgbColors: {
red: 0
}
},
Answer the question
In order to leave comments, you need to log in
Through watch
You can shove getters
in computed
And get it
const app = new Vue({
store,
el: '#app',
data() {
return {}
},
computed: {
rgbColors() {
return this.$store.getters.rgbColors
}
},
watch: {
rgbColors(newValue, oldValue) {
}
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question