最近才发现vue.$set

2018-12-13  本文已影响0人  IceCover

笔记备忘

有点失策

  data() {
      return {
        test:{
          aaa:1,
          arr:[{
            bb:'asdad'
          }]
        },
  },



 testClick(){
        this.test.aaa=123;
        this.$set(this.test,'asd',123);
        console.log(this.test)
        this.test.arr.forEach((item)=>{
          this.$set(item,'asdaasd','1sss23');
        })
      },

this.$set不一定要在data根里面的响应式对象,也可以是响应式对象中的对象添加属性

上一篇 下一篇

猜你喜欢

热点阅读