关于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挂载



免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM