Vue-component全局注册实例
时间:2021-06-18 08:46:14|栏目:vue|点击: 次
组件的全局注册必须注意是在实例化对象之前完成。
Vue.component("mytest",
{
template:'<li>{{name}}</li>',
props:['name']
})
new Vue({
//...
})
而局部注册则只能在父模板内使用
<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
下一篇:Element Table的row-class-name无效与动态高亮显示选中行背景色
本文标题:Vue-component全局注册实例
本文地址:http://www.codeinn.net/misctech/144133.html






