mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 14:39:16 +08:00
18 lines
491 B
TypeScript
18 lines
491 B
TypeScript
/**
|
|
* Create a basic component with common options
|
|
*/
|
|
import { App, defineComponent, ComponentOptionsWithObjectProps } from 'vue';
|
|
import { camelize } from '..';
|
|
|
|
export function createComponent(name: string) {
|
|
return function (sfc: ComponentOptionsWithObjectProps) {
|
|
sfc.name = name;
|
|
sfc.install = (app: App) => {
|
|
app.component(name as string, sfc);
|
|
app.component(camelize(`-${name}`), sfc);
|
|
};
|
|
|
|
return defineComponent(sfc);
|
|
} as typeof defineComponent;
|
|
}
|