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内部运行剖析读书笔记 #5

Open
DaZhaoLis opened this issue Apr 18, 2018 · 1 comment
Open

Vue内部运行剖析读书笔记 #5

DaZhaoLis opened this issue Apr 18, 2018 · 1 comment
Assignees
Labels

Comments

@DaZhaoLis
Copy link
Owner

DaZhaoLis commented Apr 18, 2018

Vue内部运行概览

vuesourceview

init的过程

initMixin: 初始化全局混入
stateMixin:
  主要做一些方便调用的api $data $props $set $delete $watch
eventsMixin:
  主要做一些事件相关的api $on $off $once $emit
lifecycleMixin:
  主要做一些生命周期函数 updated forceUpdate destroy
renderMixin:
  暴露$nextTick 声明render
init:
  为每个vue实例添加uid以区分,并根据config.performance配置来开启或关闭性能监控(组件初始化、编译、渲染和打补丁patch的性能追踪)。
  添加isVue避免被observe。
  根据是否为子组件来快速合并options还是需要根据mixin策略进行合并包括extend继承属性。
initProxy
  添加些代理来提示用户错误行为,未声明data属性并不是全局允许对象,声明重复config.keycode
允许的全局对象'Infinity,undefined,NaN,isFinite,isNaN,' +'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +'require'
  添加config.keycode的检测Proxy,若已存在的keycode则提示,不存在则报错,默认有(stop,prevent,self,ctrl,shift,alt,meta)
那其他修饰符岂不是不检测了?https://github.com/vuejs/vue/blob/1bd6196fb234c28754d9a27095afe0b5b84990ad/src/compiler/codegen/events.js
需要做下测试。
initLifecycle
  赋值parent $root 置空$children $refs watcher 生命周期:_isMounted _isDestroyed _isBeingDestroyed keep-alive的标识(_inactive _directInactive)
initEvent
  初始化事件,若option.$listener 有值的话绑定在该实例上。
initRender
  初始化$slots $scopedSlots $createElement $attrs & $listeners always updated
回调beforeCreate
initInject
  初始化$inject 并添加不可直接修改提示
initState
  初始化props methods data computed watch
initProvide
  初始化Provide并添加不可直接修改提示
回调created

@DaZhaoLis
Copy link
Owner Author

感觉没啥营养啊,不求甚解等于零啊,这体验好差。我要细究才行,要不然读源码就没意义了呀。

@DaZhaoLis DaZhaoLis added the Blog label Apr 18, 2018
@DaZhaoLis DaZhaoLis self-assigned this Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant