組件的全局注冊必須注意是在實例化對象之前完成。
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-component全局注冊實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。
新聞熱點
疑難解答