Answer the question
In order to leave comments, you need to log in
How to crawl folders and check for the presence of a file?
When developing a new application, I came to the fact that the functionality will be divided into modules.
To register all routes from each module, I import them from the specified folder and add them to the existing array:
let baseRoutes = [];
import routeCore from '@/Modules/core/routes/index';
const routes = baseRoutes.concat(routeCore);
import routeModule1 from '@/Modules/module1/routes/index';
const routes = baseRoutes.concat(routeModule1);
import routeModule2 from '@/Modules/module2/routes/index';
const routes = baseRoutes.concat(routeModule2);
//.... и так далее
export default new VueRouter({
base: '/app/',
mode: 'history',
linkActiveClass: 'has-active',
linkExactActiveClass: 'active',
routes: routes
});
/Modules/core/routes/index
/Modules/module1/routes/index.js
/Modules/module2/routes/index.js
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question