vue官网的说明
ZI1C2Q3C1)U6HN%HQQNYA1A.png

data(){
    return {
        processSteps: {
            type: 'form',
            data: [
                {
                    name: 'xiaoming',
                    age: 18
                },{
                    name: 'xiaohong',
                    age: 18
                }
            ]
        },
        list: []
    }
}
//计算属性实现的监听也不是深度监听
computed: {
    //processSteps为实例中实际用到的一个对象, 此处借助另一个变量newProcessSteps来完成监听后的处理操作
    newProcessSetps(){
        return JSON.parse(JSON.stringify(this.processSteps)))
    },
    //数组(只要有返回新数组就可以)
    newList(){
        return [...this.list]    //...展开运算符返回一个新数组
    }
},
watch: {
    newProcessSteps:{
        handler(newVal, oldVal){
            console.log(newVal, oldVal)
            //比较newVal和olcVal
            ...
            ...
        },
        deep: true
    }
}

JustForSmiling
3 声望0 粉丝