From a39c4078fe28ad773c23891f83932c8286856462 Mon Sep 17 00:00:00 2001 From: Tyh2001 <1469442737@qq.com> Date: Thu, 27 Apr 2023 10:43:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fighting-design/_hooks/use-model/index.ts | 11 ++++++----- start/src/App.vue | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/fighting-design/_hooks/use-model/index.ts b/packages/fighting-design/_hooks/use-model/index.ts index 0ddc4aee8a..c79a3e718b 100644 --- a/packages/fighting-design/_hooks/use-model/index.ts +++ b/packages/fighting-design/_hooks/use-model/index.ts @@ -1,7 +1,8 @@ import { computed } from 'vue' import type { WritableComputedRef } from 'vue' -type Emit = (key: string | number | symbol, value: T[K]) => void +/** emit 类型 */ +type Emit = (event: 'update:modelValue', val: string | number) => void export interface UseModelReturn { keyword: WritableComputedRef @@ -17,11 +18,11 @@ export interface UseModelReturn { * @param { string } emitName emit 指定的返回键名 * @returns { Object } 自定义计算属性 */ -export const useModel = , N extends keyof E>( +export const useModel = ( prop: T, propName: K, - emit: E, - emitName: N + emit: Emit, + emitName: 'update:modelValue' ): UseModelReturn => { /** @@ -34,7 +35,7 @@ export const useModel = , N extends k return prop[propName] }, set: (val: T[K]): void => { - emit(emitName, val) + emit(emitName, val as string | number) } }) diff --git a/start/src/App.vue b/start/src/App.vue index a5c6c7e1ea..d62f05af63 100644 --- a/start/src/App.vue +++ b/start/src/App.vue @@ -16,7 +16,7 @@ {{ ruleForm }} - +