获取vnode对象
- vm.$slots对象下的所有值
- vm.$scopedSlots对象的值返回一个函数,该函数执行后返回vnode对象
- directives自定义指令中钩子函数的参数3和参数4,例如钩子函数bind:
bind: function (el, binding, vnode, oldVnode) { ... )
- render渲染函数的参数1是一个返回vnode的函数,例如这里的参数h:
render: function (h) { ... }
- 函数式组件context.children返回一个vnode数组
- 函数式组件context.slots返回一个函数,该函数运行后返回一个vnode组成的对象
————————————————————————————————————————————————————
vnode构造函数传参
tag?: string,
data?: VNodeData,
children?: ?Array,
text?: string,
elm?: Node,
context?: Component,
- 函数式组件和普通组件中该值不同
componentOptions?: VNodeComponentOptions,
asyncFactory?: Function
————————————————————————————————————————————————————
vnode对象的属性
this.tag = tag
this.data = data
- 包含以下
- attrs
- class:通过v-bind绑定在组件上的class,格式和v-bind相同
- staticClass:通过字符串绑定在组件上的class
- hook
- model
- on
- props
- staticStyle:原生样式对象,通过v-bind绑定到style上的这里也会体现
- style:通过v-bind绑定到组件上的对象
this.children = children
- 当表单项插入el-form时,该值为undefined
this.text = text
this.elm = elm
this.ns = undefined
this.context = context
- rendered in this component's scope(在此组件的范围内呈现)
this.fnContext = undefined
- real context vm for functional nodes(功能节点的实上下文虚拟机)
this.fnOptions = undefined
- for SSR caching(用于SSR缓存)
this.fnScopeId = undefined
- functional scope id support(功能范围ID支持)
this.key = data && data.key
this.componentOptions = componentOptions
this.componentInstance = undefined
- component instance(组件实例)
this.parent = undefined
- component placeholder node(组件占位符节点)
this.raw = false
- contains raw HTML? (server only)(包含原始HTML)
this.isStatic = false
- hoisted static node(吊装静节点)
this.isRootInsert = true
- necessary for enter transition check(输入转换检查所必需的)
this.isComment = false
- empty comment placeholder?(空注释占位符)
this.isCloned = false
- is a cloned node?(是克隆的节点)
this.isOnce = false
- is a v-once node?
this.asyncFactory = asyncFactory
- async component factory function(异步组件工厂函数)