init project
This commit is contained in:
16
apps/web-antd/src/utils/routerHelper.ts
Normal file
16
apps/web-antd/src/utils/routerHelper.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
|
||||
const modules = import.meta.glob('../views/**/*.{vue,tsx}');
|
||||
// TODO @xingyu:这个要不要融合到哪个 router util 里?
|
||||
/**
|
||||
* 注册一个异步组件
|
||||
* @param componentPath 例:/bpm/oa/leave/detail
|
||||
*/
|
||||
export const registerComponent = (componentPath: string) => {
|
||||
for (const item in modules) {
|
||||
if (item.includes(componentPath)) {
|
||||
// 使用异步组件的方式来动态加载组件
|
||||
return defineAsyncComponent(modules[item] as any);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user