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>