vue watch监听多个值
有时候我们需要监听多个值,然后根据这几个值做出相应的操作。例如:当finishOne,finishTwo,finishThree这三个值都是true的时候,loading消失。computed: {loadingShow() {const { finishOne, finishTwo, finishThree } = this;return { finishOne, finishTwo, fini
·
有时候我们需要监听多个值,然后根据这几个值做出相应的操作。
例如:当finishOne,finishTwo,finishThree这三个值都是true的时候,loading消失。
computed: {
loadingShow() {
const { finishOne, finishTwo, finishThree } = this;
return { finishOne, finishTwo, finishThree };
},
},
watch: {
loadingShow: {
handler(newValue) {
if (newValue.finishOne && newValue.finishTwo && newValue.finishThree) {
this.$refs.loading.hide();
}
},
deep: true,
immediate: true,
},
},
更多推荐
已为社区贡献5条内容
所有评论(0)