请检查此示例。
https://codepen.io/suedar/pen/XGyGOj
单击li
后,要求div
显示不显示的内容。
我知道是因为Reactivity in Depth。
我想知道在使用vuex
时如何监视对象中的深层值。感谢您的回答。
答案 0 :(得分:0)
Deep watch
应该也可以在Vuex商店上使用。
import { mapState, mapMutations } from 'vuex';
export default {
computed: {
...mapState([
'allCategory'
])
},
methods: {
...mapMutations([
'CHANGE_ALL_CATEGORY'
]),
toggleTab(index, isShow) {
// ...some action
this.CHANGE_ALL_CATEGORY(allCategory);
},
},
watch: {
allCategory: {
handler(val) {
this.CHANGE_ALL_CATEGORY(val);
},
deep: true
}
}
}