From 23b8d203ce0d3619ca2bdfdbc911e3cc47be96e0 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Tue, 21 Mar 2023 21:34:41 +0800 Subject: [PATCH] fix: update judgment --- packages/components/input/src/input.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/components/input/src/input.vue b/packages/components/input/src/input.vue index aa7df424a0..891a14a5ca 100644 --- a/packages/components/input/src/input.vue +++ b/packages/components/input/src/input.vue @@ -379,7 +379,8 @@ const handleInput = async (event: Event) => { if (props.countGraphemes && isFunction(props.countGraphemes)) { const graphemes = props.countGraphemes(value) - if (graphemes > Number(maxlength.value) && saveValue.value) { + const saveGraphemes = props.countGraphemes(saveValue.value) + if (graphemes > Number(maxlength.value) && graphemes > saveGraphemes) { value = saveValue.value } } @@ -490,6 +491,14 @@ watch( } ) +watch( + () => nativeInputValue.value, + (val) => { + saveValue.value = val + }, + { immediate: true } +) + // native input value is set explicitly // do not use v-model / :value in template // see: https://github.com/ElemeFE/element/issues/14521