Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

了解 Vue #58

Open
MengZhaoFly opened this issue Jan 18, 2020 · 0 comments
Open

了解 Vue #58

MengZhaoFly opened this issue Jan 18, 2020 · 0 comments

Comments

@MengZhaoFly
Copy link
Owner

MengZhaoFly commented Jan 18, 2020

Runtime only

Runtime:在浏览器里面运行的时候,运行起来的代码:创建 Vue 实例,渲染,处理虚拟 dom

Runtime + Compiler

Compiler:将模板字符串编译成 js 的渲染函数的代码

new Vue({
  template: '<div></div>'
})

为什么需要 Compiler 的代码,比如上面这段代码,单纯 vue-loader 是不能分析到 这个 template。

双向绑定

image

  • {{time}} -> 可能是 vue-loader -> Directive
    一个指令对应一个 Watcher
    Watcher 监听 如果 使用了 time , 那么告诉 Dep 添加一个依赖
    更改了 time,响应式系统告诉 Dep,Dep 告诉 Watcher ,通知更新。

Observer

观察者模式
getter -> Dep.depend -> Watcher.addDep -> Dep.addSub ( Watcher 把 自身作为依赖添加 )

dep = [ watcner, watcher, wtacher ]

关于数组

劫持方法

指令

bind 类型: 对应数据的 get
update 类型:对应 数据的 set

keep-alive

LRU 算法

调度

异步更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant