createVnode
- snabbdom创建vnode比较简单, 就是遍历创建对象
- 相当于Vue里的 vm.$createElement(自己写render的时候调用,alwaysNormalize是true)或vm._c1234567891011121314151617function h(sel, data, children) {// option adapter// ...if (is.array(children)) {for (i = 0; i < children.length; ++i) {if (is.primitive(children[i]))children[i] = vnode_1.vnode(undefined, undefined, undefined, children[i]);}}return vnode_1.vnode(sel, data, children, text, undefined);}function vnode(sel, data, children, text, elm) {var key = data === undefined ? undefined : data.key;return { sel: sel, data: data, children: children,text: text, elm: elm, key: key };}
patch
- patch时和Vue是相似的, 第一次patch 对于根节点old vnode是要挂载的dom(组件的话会是undefined), 之后便是vnode的对比
- 第一次patch就是为vnode创建node, 然后替换掉el
|
|
|
|
hooks
- create
- insert
vue里的vnode hooks
1234- 0: "init"- 1: "prepatch"- 2: "insert" 组件vm的mount在这里触发 callHook(componentInstance, 'mounted');- 3: "destroy"
jsx
babel7
- https://github.com/vuejs/jsx#installation12345678Install the preset with:npm install @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-propsThen add the preset to .babelrc:{"presets": ["@vue/babel-preset-jsx"]}
babel6
- https://github.com/vuejs/babel-plugin-transform-vue-jsx
- Starting with version 3.4.0 we automatically inject const h = this.$createElement in any method and getter
依赖
|
|
写法
|
|
|
|