vuejs件同一个挂载点上切换组

vuejs件同一个挂载点上切换组

动态组件
http://cn.vuejs.org/guide/components.html#动态组件

多个组件可以使用同一个挂载点,然后动态地在它们之间切换。使用保留的 元素,动态地绑定到它的 is 特性:

new Vue({
  el: 'body',
  data: {
    currentView: 'home'
  },
  components: {
    home: { /* ... */ },
    posts: { /* ... */ },
    archive: { /* ... */ }
  }
})
<component :is="currentView">
  <!-- 组件在 vm.currentview 变化时改变 -->
</component>
原文地址:https://www.cnblogs.com/wancy86/p/5622111.html