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()

使用computed实现过滤器:

computed: { 
    filteredNames: function () { 
       let filter = new RegExp(this.findName, 'i')
       return this.names.filter(el => el.match(filter)) 
    }
 }

 vue源码查看:

在你的vue项目里,谷歌命令行键入

Object.getOwnPropertyNames(Vue)  //可以看定义在对象上的所有属性名/方法名
Vue.config
Vue.util
Vue.set.toString()  //我们平常在控制台上是看不了一个函数到底源码怎么样的,用toString()就可以啦
原文地址:https://www.cnblogs.com/thing/p/vue.html