Vue-component全局注冊(cè)實(shí)例
來源:懂視網(wǎng)
責(zé)編:小采
時(shí)間:2020-11-27 22:08:16
Vue-component全局注冊(cè)實(shí)例
Vue-component全局注冊(cè)實(shí)例:組件的全局注冊(cè)必須注意是在實(shí)例化對(duì)象之前完成。 Vue.component(mytest, { template:'<li>{{name}}</li>', props:['name'] }) new Vue({ //... }) 而局部注冊(cè)則只能在父模板內(nèi)使用 <div id=clear &
導(dǎo)讀Vue-component全局注冊(cè)實(shí)例:組件的全局注冊(cè)必須注意是在實(shí)例化對(duì)象之前完成。 Vue.component(mytest, { template:'<li>{{name}}</li>', props:['name'] }) new Vue({ //... }) 而局部注冊(cè)則只能在父模板內(nèi)使用 <div id=clear &

組件的全局注冊(cè)必須注意是在實(shí)例化對(duì)象之前完成。
Vue.component("mytest",
{
template:'<li>{{name}}</li>',
props:['name']
})
new Vue({
//...
})
而局部注冊(cè)則只能在父模板內(nèi)使用
<div id="clear" >
<mytest v-for='li in list' v-bind:name='li'>
</mytest>
</div>
var vm=new Vue({
el:'#clear',
data:{
list:[1,2,3]
},
components:{
'mytest':{
template:'<li>{{name}}</li>',
props:['name']
}
}
})
以上這篇Vue-component全局注冊(cè)實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
Vue-component全局注冊(cè)實(shí)例
Vue-component全局注冊(cè)實(shí)例:組件的全局注冊(cè)必須注意是在實(shí)例化對(duì)象之前完成。 Vue.component(mytest, { template:'<li>{{name}}</li>', props:['name'] }) new Vue({ //... }) 而局部注冊(cè)則只能在父模板內(nèi)使用 <div id=clear &