//index.html
<!DOCTYPEhtml><htmllang="en"><head><metacharset="utf-8"><title>test-vue</title><!-- 导入vue\vue-router包 --><scriptsrc="https://unpkg.com/vue/dist/vue.js"></script><scriptsrc="https://unpkg.com/vue-router/dist/vue-router.js"></script></head><body><divid="app"><h1>test test this is index.html content</h1><p><router-linkto="/app">use router-link label Go to App.vue</router-link><router-linkto="/bar">use router-link label Go to bar文件</router-link></p><router-view></router-view></div><script>//1.定义组件const App ={
template:"<div>app</div>"}const bar ={
template:"<div>bar</div>"}//2.组件和路由进行一一映射const routes =[{
path:'/app',
component: App
},{
path:"/bar",
component: bar
},]//3.创建路由实例const router =newVueRouter({
routes
})//4.创建并挂载根实例const app =newVue({
router
}).$mount('#app')</script></body></html>