一、新建router.js
import VueRouter from 'vue-router'
import accout from './main/Account.vue'
import goodsList from './main/GoodsList.vue'
import child1 from './children/child1.vue'
import child2 from './children/child2.vue'
//3、创建路由对象
var router = new VueRouter({
routes: [
{
path:'/account',
component:accout,
children: [
{path: 'child1',component: child1},
{path: 'child2',component: child2}
]
},
{path:'/goodsList',component:goodsList},
]
})
//把路由对象暴露出去
export default router
二、在main.js中导入
//导入自定义路由模块
import router from './router.js'