pagerender
Version:
18 lines (17 loc) • 554 B
JavaScript
import {defineAsyncComponent} from 'vue'
const _components = import.meta.glob('/**/*.vue')
function registerComponent(Vue,path){
for (const [key, value] of Object.entries(_components)) {
if(key.includes(path) ){
const name = key.replace(/(\.\/|.vue)/g, '').split(path + '/')[1].split('/')
//注册组件库
Vue.component(name[1], defineAsyncComponent(value))
}
}
}
export default {
install(Vue,option){
registerComponent(Vue,option.path);
Vue.component('pageRender',defineAsyncComponent(()=>import('./Core/')));
}
}