通过computed + watch
1.首先在computed中将store里的数据返回
如下:
getStoreItem(){
return this.$store.state.item
}
2.然后在watch里监听getStoreItem()的变化,并作出相应操作
getStoreItem(){
this.doSomeThing();
}
3.此时如果VUEX里的数据发生改变,会同时触发this.doSomeThing();
4.注释:此方法也可用于app.vue监听this.$route变化