Skip to content

Commit c0e192f

Browse files
committed
🔧 [input] fix input value render error
1 parent 66fad2d commit c0e192f

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

core/components/base/input/useInput.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ export default function useInput<
2323
const inputClass = isInput ? 'm-input-inner' : 'm-textarea-inner';
2424
const rowInfo = isInput ? {} : { rows: 10 };
2525

26-
const baseProps = {
27-
autofocus: props.autofocus,
28-
value: props.modelValue,
29-
placeholder: props.placeholder,
30-
disabled: props.disabled,
31-
type: props.type,
32-
readOnly: props.readonly,
26+
const renderInit = ()=>{
27+
const baseProps = {
28+
autofocus: props.autofocus,
29+
value: props.modelValue,
30+
placeholder: props.placeholder,
31+
disabled: props.disabled,
32+
type: props.type,
33+
readOnly: props.readonly,
34+
}
35+
return {
36+
baseProps
37+
}
3338
}
3439

3540
const onInput = (e: HTMLElementEvent<HTMLInputElement>)=>{
@@ -46,7 +51,7 @@ export default function useInput<
4651
}
4752

4853
return {
49-
baseProps,
54+
renderInit,
5055
inputType,
5156
inputClass,
5257
rowInfo,

headless/components/base/input/MInput.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ const { useInput, props } = InputCore;
1616

1717
export default defineComponent((props: InputProps, { emit }) => {
1818
const {
19-
baseProps,
19+
renderInit,
2020
inputType, onInput, onFocus, onBlur,
2121
inputClass,
2222
rowInfo,
2323
} = useInput(props, { emit });
2424

2525
return () => {
26+
const { baseProps } = renderInit();
27+
2628
return h(inputType, { class: 'm-input' }, {
2729
...baseProps,
2830
onInput, onFocus, onBlur,

lib/components/base/input/MInput.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ export default defineComponent((props: InputProps, { emit }) => {
2828
}));
2929

3030
const {
31-
baseProps,
31+
renderInit,
3232
inputType, onInput, onFocus, onBlur,
3333
inputClass,
3434
rowInfo,
3535
} = useInput(props, { emit });
3636

3737
return () => {
38+
39+
const { baseProps } = renderInit();
40+
3841
return h(MBorder, borderClass.value, () => h(inputType, {
3942
...baseProps,
4043
onInput, onFocus, onBlur,
@@ -47,3 +50,4 @@ export default defineComponent((props: InputProps, { emit }) => {
4750
emits: ['update:modelValue', 'focus', 'blur', 'input'],
4851
props,
4952
});
53+

0 commit comments

Comments
 (0)