(component): 调整 input 组件 input 与 change 事件, event 类型参数修改为 string 类型的 value

This commit is contained in:
就眠儀式 2022-07-28 10:35:49 +08:00
parent 31ad2ff7a3
commit fbf78dd0dd

View File

@ -39,9 +39,9 @@ const props = withDefaults(defineProps<LayInputProps>(), {
interface InputEmits { interface InputEmits {
(e: "blur", event: Event): void; (e: "blur", event: Event): void;
(e: "input", event: Event): void; (e: "input", value: string): void;
(e: "update:modelValue", value: string): void; (e: "update:modelValue", value: string): void;
(e: "change", event: Event): void; (e: "change", value: string): void;
(e: "focus", event: Event): void; (e: "focus", event: Event): void;
(e: "clear"): void; (e: "clear"): void;
} }
@ -84,7 +84,7 @@ const onInput = function (event: Event) {
const inputElement = event.target as HTMLInputElement; const inputElement = event.target as HTMLInputElement;
const value = inputElement.value; const value = inputElement.value;
emit("update:modelValue", value); emit("update:modelValue", value);
emit("input", event); emit("input", value);
}; };
const onClear = () => { const onClear = () => {
@ -97,7 +97,9 @@ const onFocus = (event: Event) => {
}; };
const onChange = (event: Event) => { const onChange = (event: Event) => {
emit("change", event); const inputElement = event.target as HTMLInputElement;
const value = inputElement.value;
emit("change", value);
}; };
const onBlur = (event: Event) => { const onBlur = (event: Event) => {