目录
image.png
login.router.js
export default {
path: '/',
name: 'login',
component: () => import('@/views/login/index.vue'),
}
index.js
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routerList = []
function importAll(r) {
r.keys().forEach(item => routerList.push(r(item).default))
}
importAll(require.context('./', false, /\.router\.js/))
console.log(routerList)
const routes = [...routerList]
const router = new VueRouter({
routes,
})
export default router
image.png
网友评论