You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classWatcher{constructor(vm,expr,cb){this.vm=vmthis.expr=exprthis.cb=cb// old valuethis.oldValue=this.get()}get(){Dep.target=thisletvalue=CompileUtil.getVal(this.vm,this.expr)Dep.target=nullreturnvalue}update(){letnewVal=CompileUtil.getVal(this.vm,this.expr)if(newVal!==this.oldValue){this.cb(newVal)}}}
2020-10-26 23:52:23
MVVM 模块
VUE 模块主要负责所有模块的数据和初始化一些功能 比如执行编译模版、Computed、Methods、挂载 $data
编译模版
数据劫持
劫持 所有 data 数据,并且新数据也需要劫持
监听 观察者 Watcher
观察者 Watcher 数据变化更新视图
维护 Dep 订阅者 Observer Set 的时候通知所有观察者
Compile 里面 new Watcher 和 Observer 绑定起来
------------------ all code ------------------
The text was updated successfully, but these errors were encountered: