vue动态组件加载
1.html<component :is="currentView" ></component>2.jsVue.component("child1", {template: '<p>hell child1</p>'})Vue.component(&
·
1.html
<component :is="currentView" ></component>
2.js
Vue.component("child1", {
template: '<p>hell child1</p>'
})
Vue.component("child2", {
template: '<p>hell child2</p>'
})
new Vue({
el: '#root',
data: {
currentView: 'child1',
active: 0,
tabs: [
{
type: 'child1 tab',
view: 'child1'
},{
type: 'child2 tab',
view: 'child2'
}
]
},
methods: {
toggle(i,v) {
this.active = i
this.currentView = v
}
}
})
参考:https://jsfiddle.net/2kn4hqts/
更多推荐
已为社区贡献22条内容
所有评论(0)