Vue_使用watch监听对象的三种方法

            data: {
                datas: {
                    a: 77,
                    b: 86
                }
            }

使用deep:true深层次监听

                'datas':{
                    handler:function(newVal){
                        console.log(this.datas);
                    },
                    deep:true
                }

监听某一个具体的属性

                'datas.a':{
                    handler:function(newVal){
                        console.log(this.datas);
                    }
                }

使用computed来监听某一个具体的属性

            watch: {
                a(newVal){
                    console.log(this.datas);
                }
            },
            computed: {
                a:function(){
                    return this.datas.a;
                }
            }
posted @ 2021-01-16 17:57  Syinho  阅读(665)  评论(0编辑  收藏  举报