监听vuex中state内某个字段的变化,触发模块中执行函数的写法

        watch:{
getorderid(curval,oldval){   //监听了computed中getorderid的值,如果发生改变就触发console.log
console.log(`最新值${curval}--旧值${oldval}`);
}
},
computed:{      //同步了store中state内的orderid值
getorderid(){
return this.$store.state.orderid;
}
}

猜你喜欢

转载自blog.csdn.net/aliven1/article/details/80881257
今日推荐