Vue中的$set的使用 (为对象设置属性)

data() {
   return {
     obj: {
       name: 'shun'
    }
  }
 }

对象只有name属性,通过$set给对象添加属性(三个参数,对象名,属性名, 属性)

setage() {
      this.$set(this.obj, 'age', 18)
    }

猜你喜欢

转载自www.cnblogs.com/shun1015/p/12731683.html