vue零碎收集

在组件中创建dom:

      let a=document.querySelector('.test');
      let newDom=document.createElement("div"); // 创建dom
      newDom.setAttribute("class","testAdd" ); // 添加样式
      a.appendChild(newDom); // 插入dom

数组与对象的更新:

 this.$set(你要改变的数组/对象,你要改变的位置/key,你要改成什么value)
 this.$set(this.arr, 0, "OBKoro1"); // 改变数组
 this.$set(this.obj, "c", "OBKoro1"); // 改变对象

  或者:数组原生方法触发视图更新:

    splice()、 push()、pop()、shift()、unshift()、sort()、reverse()

猜你喜欢

转载自www.cnblogs.com/thing/p/vue.html