@dada-element/utils
Advanced tools
+0
-2
@@ -1,3 +0,1 @@ | ||
| export * from './src/with-install' | ||
| export * from './src/format' |
+6
-2
| { | ||
| "name": "@dada-element/utils", | ||
| "version": "1.0.0", | ||
| "version": "1.2.0", | ||
| "description": "utils for dada element", | ||
@@ -17,3 +17,7 @@ "author": "gjssss", | ||
| "src" | ||
| ] | ||
| ], | ||
| "publishConfig": { | ||
| "registry": "https://registry.npmjs.org/", | ||
| "access": "public" | ||
| } | ||
| } |
| import type { App, Component } from 'vue' | ||
| import { camelize } from './format' | ||
| export type WithInstall<T> = T & { | ||
| install(app: App): void | ||
| } | ||
| export function withInstall<T extends Component>(options: T) { | ||
| (options as Record<string, unknown>).install = (app: App) => { | ||
| const { name } = options | ||
| if (name) { | ||
| // 同时注册两种命名方式的组件 | ||
| app.component(name, options) | ||
| app.component(camelize(`-${name}`), options) | ||
| } | ||
| } | ||
| return options as WithInstall<T> | ||
| } |
1695
-21.2%3
-25%39
-30.36%