关于`render: h => h(App)`的解释

vue项目中,在实例化Vue对象的时候,经常会看到以下两段代码,如果没有了解过Vue2.0里新增的Vue选项中的 render 函数,第一段代码看起来就很容易不理解了。除了文档,官方也在issues里面回答过这个问题,这里仅作个记录。

Vue 2.0时代

new Vue({
    router,
    render: h => h(App)   
}).$mount('#app')

Vue 1.0时代

new Vue({
    el: '#app',
    components: { App }
})

答案链接:https://github.com/vuejs-templates/webpack-simple/issues/29
文档链接:https://cn.vuejs.org/v2/api/#render

posted @ 2019-07-19 15:57  近距离  阅读(198)  评论(0编辑  收藏  举报