From 47ad40794e2c992d6d23a2739a87003d64a4f509 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 26 Jul 2020 16:32:46 +0800 Subject: [PATCH] fix: failed to install component --- src/utils/create/component.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/utils/create/component.ts b/src/utils/create/component.ts index 90e316e3f..6117f69f0 100644 --- a/src/utils/create/component.ts +++ b/src/utils/create/component.ts @@ -1,17 +1,16 @@ /** * Create a basic component with common options */ - -// function install(this: any, Vue: VueConstructor) { -// const { name } = this; -// Vue.component(name as string, this); -// Vue.component(camelize(`-${name}`), this); -// } +import { camelize } from '../format/string'; +import type { App, ComponentOptions } from 'vue'; export function createComponent(name: string) { - return function (sfc: any) { + return function (sfc: ComponentOptions) { sfc.name = name; - // sfc.install = install; + sfc.install = (app: App) => { + app.component(name as string, sfc); + app.component(camelize(`-${name}`), sfc); + }; return sfc; };