File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -60,13 +60,26 @@ const emit = defineEmits<{
6060
6161const onInput = (e : Event ) => {
6262 const el = e .target as HTMLInputElement ;
63- let val = Number ( el .value ) ;
63+ const raw = el .value ;
6464
65- if (props .min !== null && props . min !== undefined && val < props . min ) val = props . min ;
66- if ( props . max !== null && props . max !== undefined && val > props . max ) val = props . max ;
65+ if (props .type === ' number ' ) {
66+ const num = Number ( raw ) ;
6767
68- el .value = String (val );
69- emit (' update:modelValue' , val );
68+ if (isNaN (num )) {
69+ emit (' update:modelValue' , null );
70+ return ;
71+ }
72+
73+ let val = num ;
74+
75+ if (props .min != null && val < props .min ) val = props .min ;
76+ if (props .max != null && val > props .max ) val = props .max ;
77+
78+ el .value = String (val );
79+ emit (' update:modelValue' , val );
80+ } else {
81+ emit (' update:modelValue' , raw );
82+ }
7083};
7184
7285
You can’t perform that action at this time.
0 commit comments