[聚合文章] vue中watch用法

vue.js 2017-11-22 11 阅读
/*
    position:{x:0,y:0}
*/
export default{
    watch:{
         position:{
            handler:function(cur,old){
                // 此处如果写成箭头函数则无法获取this对象
                this.point.x = cur.x;
            },
            //深度观察
            deep:true
        },
        text:{
            handler:(cur,old)=>{
                console.log(cur);
            }
        },
        treedata(cur,old){
            console.log(cur);
        }        
    }
}

注:本文内容来自互联网,旨在为开发者提供分享、交流的平台。如有涉及文章版权等事宜,请你联系站长进行处理。