SOURCE

console 命令行工具 X clear

                    
>
console
const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }

// 路由
const routes = [
  { path: '/foo', component: Foo },
  { path: '/bar', component: Bar }
]

const router = new VueRouter({
  routes
})

const app = new Vue({
  router
}).$mount('#app')
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>

<div id="app">
  <h1>MVVM Router</h1>
  <p>
    <router-link to="/foo">切换到 foo 页面</router-link>
    <router-link to="/bar">切换到 bar 页面</router-link>
  </p>
  <!-- 路由出口 -->
  <!-- 路由匹配到的组件将渲染在这里 -->
  <router-view></router-view>
</div>