用watch去監(jiān)聽vuex里面state值的變化:
1、子組件存值:
this.$store.commit("updateBrand", res.data.name);
2、父組件內使用watch去監(jiān)聽vuex值的變化:
watch: {
"$store.state.name"(newval, olval) {
console.log(newval);
},
}
用watch去監(jiān)聽vuex里面state值的變化:
1、子組件存值:
this.$store.commit("updateBrand", res.data.name);
2、父組件內使用watch去監(jiān)聽vuex值的變化:
watch: {
"$store.state.name"(newval, olval) {
console.log(newval);
},
}