build(pinia): Add pinia
build(vite-plugin-vue-setup-extend): Delete vite-plugin-vue-setup-extend build(unplugin-auto-import): Delete unplugin-auto-import build(unplugin-vue-components): Delete unplugin-vue-components build(vite-plugin-style-import): Add vite-plugin-style-import
This commit is contained in:
18
src/utils/index.ts
Normal file
18
src/utils/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { App, Plugin } from 'vue'
|
||||
|
||||
/**
|
||||
*
|
||||
* @param component 需要注册的组件
|
||||
* @param alias 组件别名
|
||||
* @returns any
|
||||
*/
|
||||
export const withInstall = <T>(component: T, alias?: string) => {
|
||||
const comp = component as any
|
||||
comp.install = (app: App) => {
|
||||
app.component(comp.name || comp.displayName, component)
|
||||
if (alias) {
|
||||
app.config.globalProperties[alias] = component
|
||||
}
|
||||
}
|
||||
return component as T & Plugin
|
||||
}
|
||||
Reference in New Issue
Block a user