0

比如 router/index.js 中配置router对象:

Vue.use(Router)
export default new Router({
  mode: 'hash', // Demo is living in GitHub.io, so required!
  // history: true,
  // saveScrollPosition: true,
  linkActiveClass: 'open active',
  scrollBehavior: () => ({ y: 0 }),
  routes: [

其中大部分内容为固定格式:

            { path: 'doc01', name: 'doc01', component: require('../urls/edit/Doc01.vue') },
            { path: 'doc02', name: 'doc02', component: require('../urls/edit/Doc02.vue') },
            { path: 'doc03', name: 'doc03', component: require('../urls/edit/Doc03.vue') },
            { path: 'doc04', name: 'doc04', component: require('../urls/edit/Doc04.vue') },
            { path: 'doc05', name: 'doc05', component: require('../urls/edit/Doc05.vue') },
            { path: 'doc06', name: 'doc06', component: require('../urls/edit/Doc06.vue') },
            { path: 'doc07', name: 'doc07', component: require('../urls/edit/Doc07.vue') },
            ........

可否通过规则自动生成上面的代码?

Vanghohs 137
2018-03-13 提问
3 个回答
0

直接遍历不就行了?

0

能给个代码参考下吗?

0

nuxt.js这个就可以自动生成路由,
你也可以自己用node封装一个

撰写答案

你可能感兴趣的

推广链接