随着项目越来越大,把所有route写在一个文件里就显得杂乱。
#单个组件路由
import a from '../components/a'
export default {
path: '/a',
name: 'a',
component: a
}
import arouter from 'xxx'
export default new Router({
routes: [
arouter
]
})
#多个组件路由
import a from '../components/a'
import b from '../components/b'
export default [{
path: '/a',
name: 'a',
component: a
}, {
path: '/b',
name: 'b',
component: b
}]
#arouter.js
export default new Router({
routes: [
...arouter//扩展运算符
]
})
网友评论