diff --git a/packages/components/input/__tests__/input.test.tsx b/packages/components/input/__tests__/input.test.tsx index 28d1630827..ff8f38b067 100644 --- a/packages/components/input/__tests__/input.test.tsx +++ b/packages/components/input/__tests__/input.test.tsx @@ -71,17 +71,17 @@ describe('Input.vue', () => { const elCount = wrapper.find('.el-input__count-inner') expect(elCount.exists()).toBe(true) - expect(elCount.text()).toMatchInlineSnapshot(`"3 / 4"`) + expect(elCount.text()).toMatchInlineSnapshot(`"4 / 4"`) inputVal.value = '1👌3😄' await nextTick() expect(nativeInput.value).toMatchInlineSnapshot(`"1👌3😄"`) - expect(elCount.text()).toMatchInlineSnapshot(`"4 / 4"`) + expect(elCount.text()).toMatchInlineSnapshot(`"6 / 4"`) inputVal.value = '哈哈1👌3😄' await nextTick() expect(nativeInput.value).toMatchInlineSnapshot(`"哈哈1👌3😄"`) - expect(elCount.text()).toMatchInlineSnapshot(`"6 / 4"`) + expect(elCount.text()).toMatchInlineSnapshot(`"8 / 4"`) expect(Array.from(vm.$el.classList)).toMatchInlineSnapshot(` [ "el-input", @@ -108,12 +108,12 @@ describe('Input.vue', () => { const elCount = wrapper.find('.el-input__count') expect(elCount.exists()).toBe(true) - expect(elCount.text()).toMatchInlineSnapshot(`"3 / 4"`) + expect(elCount.text()).toMatchInlineSnapshot(`"4 / 4"`) inputVal.value = '哈哈1👌3😄' await nextTick() expect(nativeInput.value).toMatchInlineSnapshot(`"哈哈1👌3😄"`) - expect(elCount.text()).toMatchInlineSnapshot(`"6 / 4"`) + expect(elCount.text()).toMatchInlineSnapshot(`"8 / 4"`) expect(Array.from(vm.$el.classList)).toMatchInlineSnapshot(` [ "el-textarea", diff --git a/packages/components/input/src/input.vue b/packages/components/input/src/input.vue index f2a6840e58..1b8d1bbd6a 100644 --- a/packages/components/input/src/input.vue +++ b/packages/components/input/src/input.vue @@ -293,7 +293,7 @@ const isWordLimitVisible = computed( !props.readonly && !props.showPassword ) -const textLength = computed(() => Array.from(nativeInputValue.value).length) +const textLength = computed(() => nativeInputValue.value.length) const inputExceed = computed( () => // show exceed style if length of initial value greater then maxlength