看文檔都是生成組件,功能一樣吧?
Vue.extend和Vue.Component出來的組件有什么異同?
開滿天機
2018-12-13 14:13:00
TA貢獻1810條經驗 獲得超4個贊
extend 是構造一個組件的語法器.
你給它參數 他給你一個組件 然后這個組件
你可以作用到Vue.component 這個全局注冊方法里, 也可以在任意vue模板里使用<apple>組件
var apple = Vue.extend({
....
})
Vue.component('apple',apple)
你可以作用到vue實例或者某個組件中的components屬性中并在內部使用apple組件
new Vue({
components:{
apple:apple
}
})
Vue.component 你可以創建 ,也可以取組件 例如下
var apple = Vue.component('apple')
new Vue就是創建一個vue實例咯 返回一個vm實例 。api中vm的說明就是new Vue創建的
希望可以加深你理解
舉報