有时候我们需要监听多个值,然后根据这几个值做出相应的操作。

例如:当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,
        },
    },

Logo

前往低代码交流专区

更多推荐