diff --git a/package/component/src/component/input/index.vue b/package/component/src/component/input/index.vue index 430a00bd..9455e383 100644 --- a/package/component/src/component/input/index.vue +++ b/package/component/src/component/input/index.vue @@ -16,7 +16,7 @@ export interface LayInputProps { value?: string; disabled?: boolean; readonly?: boolean; - modelValue?: string; + modelValue?: string | number; placeholder?: string; allowClear?: boolean; autofocus?: boolean; @@ -44,7 +44,7 @@ const emit = defineEmits([ const { t } = useI18n(); const slots = useSlots(); -const hasContent = computed(() => props.modelValue?.length > 0); +const hasContent = computed(() => (props.modelValue as string)?.length > 0); const onInput = function (event: Event) { const inputElement = event.target as HTMLInputElement; diff --git a/package/component/src/component/inputNumber/index.vue b/package/component/src/component/inputNumber/index.vue index 4357765b..b20bf529 100644 --- a/package/component/src/component/inputNumber/index.vue +++ b/package/component/src/component/inputNumber/index.vue @@ -9,7 +9,7 @@ import "./index.less"; import layInput from "../input/index.vue"; import { LayIcon } from "@layui/icons-vue"; import layButton from "../button/index.vue"; -import { ref, watch, withDefaults, computed } from "vue"; +import { ref, watch, withDefaults, computed, Ref } from "vue"; export interface LayInputNumberProps { modelValue?: number; @@ -33,7 +33,7 @@ const props = withDefaults(defineProps(), { }); const emit = defineEmits(["update:modelValue", "change"]); -let num = ref(props.modelValue); +let num: Ref = ref(props.modelValue); watch(num, (val) => { if (props.max !== Infinity && val > props.max) { @@ -107,7 +107,7 @@ const isNumber = function (num: any) {