vue对象render函数的三种实现
import App from './app.vue' const root = document.createElement('div'); document.body.appendChild(root);
第一种方式($createElement):
//写法三:
const rootVue = new Vue(
{
router: vueRouter,
render: function () {
// return this.$createElement('p', 'hi');
const h = this.$createElement; //h是一个函数类型变量
return h(App);
}
}
).$mount(root)第二种方式:
new Vue(
{
//createElementFunction 是一个函数类型变量
render: function (createElementFunction) {
return createElementFunction(App);
}
}
).$mount(root)
第三种写法:
new Vue(
{ //es6语法之箭头函数
render: (h) => h(App)
}
).$mount(root)本文内容仅供个人学习/研究/参考使用,不构成任何决策建议或专业指导。分享/转载时请标明原文来源,同时请勿将内容用于商业售卖、虚假宣传等非学习用途哦~感谢您的理解与支持!