vue双向绑定引发的思考

const a={
  _b:5,
};
Object.defineProperty(a,'c',{
    get:function(){
console.log('?');
        this._b=this._b-1
        return this._b;
    },    
    set:function(newValue){
console.log('#');
        return this._b=newValue;
    }
})
!function(){

console.log(a.c) //3
   a.c=10;
  console.log(a.c) //3

}();

猜你喜欢

转载自blog.csdn.net/qq_39571197/article/details/81946362