摘要: 为了实现 “ 数据修改导致视图发生 “ 我们选择使用发布订阅模式 以下是简单的发布订阅模式的实现 ------------------------------------------------- function Dep() { this.watchers=[]; } Dep.prototype.add=function (watcher) { this.watchers.... 阅读全文
posted @ 2018-01-05 14:34 哟哟sir 阅读(407) 评论(0) 推荐(0) 编辑
摘要: 上一节实现了对data的数据深度劫持,以及到实例上的挂载,此次主要解决的问题是对模板进行编译//编译 function compile(el,vm) { //获取el模板 el = vm.$el = document.querySelector(el); //将el模板转入内存中 let frg = document.createDocumentFragment(... 阅读全文
posted @ 2018-01-05 14:23 哟哟sir 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 接下来是js逻辑的实现部分: 1,通过Object.defineProperty对data上的属性实现深度数据劫持 阅读全文
posted @ 2018-01-05 13:54 哟哟sir 阅读(227) 评论(0) 推荐(0) 编辑