在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掛載