一、定义全局注册的组件,其中的组件为函数式组件:

import Vue from 'vue'
Vue.component('my-functional-component2', {
functional: true,
// Props 是可选的
props: {
username: String
},
// 为了弥补缺少的实例
// 提供第二个参数作为上下文
render: function (createElement, context) {
return createElement('h1',context.props.username)
}
})

二、使用全局注册的组件:

<my-functional-component2 username="david"></my-functional-component2>