Skip to content

vnode渲染组件

vnode是无法直接显示再html中的,使用组件将vnode直接渲染出来在一些场景是很有必要的

如下,这是一个直接在components中定义的组件

js
components: {
    RenderDom: {
      props: {
        vNode: [Array, String, Object, Number] // 这里不一定是vnode,直接传字符串和数字也可以
      },
      render (h) {
        if (typeof this.vNode === 'object') {
          return this.vNode
        } else {
          return h('div', this.vNode)
        }
      }
    }
}

鄂ICP备19018246号-1