refactor(components): [input] get maxlength and minlength from props instead of attrs (#15212)

* refactor(components): [input] get maxlength and minlength from props

* refactor: remove default
This commit is contained in:
一只前端汪
2023-12-21 14:30:57 +08:00
committed by GitHub
parent 6131becdb6
commit c4dac14f1b
3 changed files with 20 additions and 7 deletions

View File

@ -31,6 +31,8 @@
ref="input"
:class="nsInput.e('inner')"
v-bind="attrs"
:minlength="minlength"
:maxlength="maxlength"
:type="showPassword ? (passwordVisible ? 'text' : 'password') : type"
:disabled="inputDisabled"
:formatter="formatter"
@ -81,7 +83,7 @@
</el-icon>
<span v-if="isWordLimitVisible" :class="nsInput.e('count')">
<span :class="nsInput.e('count-inner')">
{{ textLength }} / {{ attrs.maxlength }}
{{ textLength }} / {{ maxlength }}
</span>
</span>
<el-icon
@ -134,7 +136,7 @@
:style="countStyle"
:class="nsInput.e('count')"
>
{{ textLength }} / {{ attrs.maxlength }}
{{ textLength }} / {{ maxlength }}
</span>
</template>
</div>
@ -304,7 +306,7 @@ const showPwdVisible = computed(
const isWordLimitVisible = computed(
() =>
props.showWordLimit &&
!!attrs.value.maxlength &&
!!props.maxlength &&
(props.type === 'text' || props.type === 'textarea') &&
!inputDisabled.value &&
!props.readonly &&
@ -314,8 +316,7 @@ const textLength = computed(() => nativeInputValue.value.length)
const inputExceed = computed(
() =>
// show exceed style if length of initial value greater then maxlength
!!isWordLimitVisible.value &&
textLength.value > Number(attrs.value.maxlength)
!!isWordLimitVisible.value && textLength.value > Number(props.maxlength)
)
const suffixVisible = computed(
() =>