update 优化 避免重复包装

This commit is contained in:
疯狂的狮子Li
2026-03-25 10:32:45 +08:00
parent 1442d539e8
commit 13a41679bc
+7 -4
View File
@@ -12,6 +12,7 @@ interface Options {
export function createCustomNameComponent(loader: () => Promise<any>, options: Options = {}): () => Promise<Component> {
const { name } = options;
let component: Component | null = null;
let wrappedComponent: Component | null = null;
const load = async () => {
try {
@@ -27,13 +28,15 @@ export function createCustomNameComponent(loader: () => Promise<any>, options: O
await load();
}
return Promise.resolve(
defineComponent({
if (!wrappedComponent) {
wrappedComponent = defineComponent({
name,
render() {
return h(component as Component);
}
})
);
});
}
return Promise.resolve(wrappedComponent);
};
}