關於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