用watch去监听vuex里面state值的变化:
1、子组件存值:
this.$store.commit("updateBrand", res.data.name);
2、父组件内使用watch去监听vuex值的变化:
watch: {
"$store.state.name"(newval, olval) {
console.log(newval);
},
}
用watch去监听vuex里面state值的变化:
1、子组件存值:
this.$store.commit("updateBrand", res.data.name);
2、父组件内使用watch去监听vuex值的变化:
watch: {
"$store.state.name"(newval, olval) {
console.log(newval);
},
}