// ES5
(function (h) {
return h(App);
}); // ES6
h => h(App);
官方文档
render: function (createElement) {
return createElement(
'h' + this.level, // tag name 标签名称
this.$slots.default // 子组件中的阵列
)
}
h是Vue.js 里面的 createElement 函数,这个函数的作用就是生成一个 VNode节点,render 函数得到这个 VNode 节点之后,返回给 Vue.js 的 mount 函数,渲染成真实 DOM 节点,并挂载到根节点上。
函数只有一个参数的时候()可以省略;当函数体只有一句话{}可以省略,所以 render: (h) => {h(App)};
就变成 render: h => h(App);
等价于components: { App },template: '<App/>'