吉安感知网项目-前端
shuishen
2026-03-05 d75d83bd2a1f4e13634f84f8a4de1f7457187b2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { defineAsyncComponent } from 'vue'
 
export default {
    install(app) {
        // 匹配当前目录下所有.vue文件(包括子目录)
        const components = import.meta.glob('./global/*.vue', { eager: true })
 
        for (const [path, module] of Object.entries(components)) {
            // 提取组件名(去除路径和扩展名)
            const name = path.split('/').pop()?.replace('.vue', '') || ''
            // 注册组件
            app.component(name, module.default)
        }
    },
}