router/index.js
导入Vue和路由插件VueRouter
导入自定义组件
import Vue from 'vue'
import VueRouter from 'vue-router'
const Home = () => import('../home/Home')
const Profile = () => import('../profile/Profile')
1.安装插件Vue.use(VueRouter)
2.创建路由对象
const routes = [
{
path:'',
redirect:'/home'
},
{
path:'/home',
component:Home
},
{
path:'/home',
component:Home
}
]
const router = new VueRoute({
routes
})
3.导出路由export default router
App.vue
1.导入
new Vue({
el:'#app',
router,
render:h => h(App)
})
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。