
vue
文章平均质量分 57
Insist_bin
这个作者很懒,什么都没留下…
展开
-
一文彻底弄清楚虚拟DOM和diff算法
什么是虚拟DOM用JS对象数据结构表示 DOM 树的结构,然后用这棵树构建一个真正的树。当状态变更的时候,重新构造一棵新的对象树,然后用新的树和旧的树进行比较,记录两棵树差异。把 2 所记录的差异应用到步骤 1 所构建的真正的 DOM 树上,视图就更新了。如何比较两棵虚拟DOM树的差异就是diff算法的作用。diff算法有几个规则:key是节点的唯一标识,只有通过key,才能告诉diff算法,在更改前后它们是同一个DOM节点只有是同一个虚拟节点,才会进行精细化比较。否则就是暴力删除旧的、插入原创 2021-07-28 16:12:51 · 405 阅读 · 0 评论 -
You are using the runtime-only build of Vue where the template compiler is not available. Either pre
在升级脚手架到vue-cli3.0版本的时候出现了这个报错:[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.我在这里大概说一下出现这个报错的原因在哪里和解决办法..原创 2021-07-28 16:05:33 · 625 阅读 · 0 评论 -
Vue 双向数据绑定原理及实现
class Vue { constructor(option) { // 1. 保存数据 this.$options = option this.$data = option.data this.$el = option.el // 2. 将 data 中数据保存到响应式系统中 new Observer(this.$data) // 3. 代理 this.$data 的数据 Object.keys(this.$data).forEac.原创 2020-07-27 09:22:52 · 219 阅读 · 0 评论 -
vue-print-nb 解决 vue 打印问题,并且隐藏页眉页脚
1、通过 npm 安装 vue-print-nbnpm install vue-print-nb --save2、挂载到 Vue 上import Print from 'vue-print-nb'Vue.use(Print)3、配置打印对象<div id="main">这里是要打印的东西</div><!-- 打印按钮,通过 v-print 调用打印事件 --><button v-print="printObj">打印<原创 2020-07-20 23:43:31 · 16550 阅读 · 7 评论