router 类似Vuex实现组件化开发的示例

随着项目越来越大,把所有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//扩展运算符 ] })

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyzpfs.html