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/


Logo

前往低代码交流专区

更多推荐