初始化

This commit is contained in:
robin
2022-07-07 22:24:46 +08:00
commit 72b69615b6
42 changed files with 10068 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
const Foo = {template: '<div>foo</div>'}
const Bar = {template: '<div>bar</div>'}
const routes = [
]
const files = require.context('../../pages', true, /index\.vue$/); //批量读取模块文件
const plugin = files.keys().reduce((modules, path) => {
const name = path.replace(/^\.\/(.*)\.vue$/, '$1');
const module = files(path).default;
//自动加载路由
routes.push(
{path: '/pages/' + name, component: module},
)
return modules;
}, {});
console.log(routes);
export default routes;