从A页面去到B页面然后再回到A页面,这样的轮回有多少次就会导致watch中的方法执行多少次。这是为什么呢?
computed: {
...mapState({
timeStamp: state => state.finishNormalOrder.timeStamp,
id: state => state.finishNormalOrder.id,
drop: state => state.finishNormalOrder.drop,
reasonName: state => state.finishNormalOrder.reasonName,
reasonId: state => state.finishNormalOrder.reasonId,
userId: state => state.finishNormalOrder.userId,
userName: state => state.finishNormalOrder.userName,
remindType: state => state.finishNormalOrder.remindType,
signed: state => state.finishNormalOrder.signed,
signImage: state => state.finishNormalOrder.signImage,
labelList: (state) => {
return state.finishNormalOrder.labelList;
},
imageList: state => state.finishNormalOrder.imageList
}),
content: {
get() {
return this.$store.state.finishNormalOrder.content;
},
set(val) {
this.updateOrder({ content: val });
}
}
},
watch: {
reasonId(value) {
console.log(value)
this.queryLabel(value);
}
},
methods: {
...mapMutations({
updateOrder: 'finishNormalOrder/updateOrder'
}),
}
3 个回复
牵着蜗牛散步
同样遇到这个问题 watch vuex中的state数据 会触发多次
Azikou
23年了, 还是没人解答/
huangjianshu
应该是页面跳转的问题
/**
*/
navigateTo(options: UniNamespace.NavigateToOptions): void;
/**
*/
redirectTo(options: UniNamespace.RedirectToOptions): void;