What is the difference between vm.$set and Vue.set?

后端 未结 3 1141
小鲜肉
小鲜肉 2020-12-23 20:12

I have carefully read and re-read the Vue docs \"Reactivity in Depth\" and the API for vm.$set and Vue.set but I am still having a difficult time determining when to use whi

3条回答
  •  心在旅途
    2020-12-23 21:13

    found that add more than one attribute to an object with .$set() only once works well, maybe Vue firstly collected these added attributes to a sequence and then apply these sequence to the getter and setter; e.g.

    Vue.set(this.b,'first','first');
    this.b.second = 'second';
    this.b.third = 'third';
    this.b.fourth = 'fourth';
    

    'second','third','fourth' are alse reactive as 'first'

提交回复
热议问题