Skip to content

Commit b1dd6c0

Browse files
vaebekagol
authored andcommitted
fix(input): 绑定数据为 ref(null) 导致无法获取 length 的错误 (close DevCloudFE#1329)
1 parent dd1e9ed commit b1dd6c0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/devui-vue/devui/input/src/input.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export default defineComponent({
4040
const suffixVisible = ctx.slots.suffix || props.suffix || props.showPassword || props.clearable;
4141

4242
const showPwdVisible = computed(() => props.showPassword && !inputDisabled.value);
43-
const showClearable = computed(() => props.clearable && !inputDisabled.value);
43+
const showClearable = computed(() => {
44+
return props.clearable && !inputDisabled.value && modelValue.value?.length > 0;
45+
});
4446

4547
watch(
4648
() => props.modelValue,
@@ -89,7 +91,7 @@ export default defineComponent({
8991
onClick={clickPasswordIcon}
9092
/>
9193
)}
92-
{showClearable.value && modelValue.value.length > 0 && (
94+
{showClearable.value && (
9395
<Icon size={inputSize.value} class={ns.em('clear', 'icon')} name="close" onClick={onClear} />
9496
)}
9597
</span>

0 commit comments

Comments
 (0)