关于render: h => h(App)和components: { App }的区别

在main.js中:常会有

new Vue({
el: '#app',
router,//实例化,表示会使用
render: h => h(App)//vue2.0写法

//以下是vue1.0的写法
//components: { App },//注册组件信息
// template: '<App/>'//简写的模板调用组件的标签
})

components: { App }
 template: '<App/>'
或者

render: h => h(App)的代码。
render:function(h){
      return h(App)
      }
render:function(createElement){
  return createElement(App)    
  }
实际上这两行代码的作用是一样的,
只是render: h => h(App)是 vue2.0的语法
      components: { App }是vue1.0的语法,
作用是渲染视图,并给el挂载


原文地址:https://www.cnblogs.com/chenlongsheng/p/9830816.html