mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-17 21:32:51 +08:00
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:
@ -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(
|
||||
() =>
|
||||
|
Reference in New Issue
Block a user