🐛: 修复 withInstall
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
export * from "./domUtil";
|
||||
export * from "./guidUtil";
|
||||
export * from "./install";
|
||||
export * from "./withInstall";
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import type { App } from "vue";
|
||||
import i18n from "../language";
|
||||
|
||||
export const withInstall = (comp: any) => {
|
||||
comp.install = (app: App | any) => {
|
||||
if (
|
||||
!app._instance?.isCE &&
|
||||
!app._instance?.appContext?.app?.__VUE_I18N_SYMBOL__
|
||||
) {
|
||||
app.use(i18n);
|
||||
}
|
||||
|
||||
app.component(comp.name, comp);
|
||||
};
|
||||
|
||||
return comp;
|
||||
};
|
||||
17
package/component/src/utils/withInstall.ts
Normal file
17
package/component/src/utils/withInstall.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { App, Plugin } from "vue";
|
||||
import i18n from "../language";
|
||||
|
||||
export type WithInstallType<T> = T & Plugin;
|
||||
|
||||
export const withInstall = <T>(comp: T): T & Plugin => {
|
||||
const component = comp as any;
|
||||
|
||||
component.install = (app: App | any) => {
|
||||
if (!app.__VUE_I18N_SYMBOL__) {
|
||||
app.use(i18n);
|
||||
}
|
||||
app.component(component.name, comp);
|
||||
};
|
||||
|
||||
return component as T & Plugin;
|
||||
};
|
||||
Reference in New Issue
Block a user