mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Field): incorrect count of line break in safari (#5049)
This commit is contained in:
parent
f8c130d0cb
commit
1c03d5d3f3
@ -2,10 +2,7 @@
|
||||
<demo-section>
|
||||
<demo-block :title="$t('basicUsage')">
|
||||
<van-cell-group>
|
||||
<van-field
|
||||
v-model="value"
|
||||
:placeholder="$t('usernamePlaceholder')"
|
||||
/>
|
||||
<van-field v-model="value" :placeholder="$t('usernamePlaceholder')" />
|
||||
</van-cell-group>
|
||||
</demo-block>
|
||||
|
||||
@ -69,10 +66,7 @@
|
||||
:placeholder="$t('smsPlaceholder')"
|
||||
>
|
||||
<template #button>
|
||||
<van-button
|
||||
size="small"
|
||||
type="primary"
|
||||
>
|
||||
<van-button size="small" type="primary">
|
||||
{{ $t('sendSMS') }}
|
||||
</van-button>
|
||||
</template>
|
||||
|
@ -18,8 +18,9 @@ export default createComponent({
|
||||
leftIcon: String,
|
||||
rightIcon: String,
|
||||
clearable: Boolean,
|
||||
labelClass: null,
|
||||
maxlength: [Number, String],
|
||||
labelWidth: [Number, String],
|
||||
labelClass: null,
|
||||
labelAlign: String,
|
||||
inputAlign: String,
|
||||
errorMessage: String,
|
||||
@ -101,9 +102,9 @@ export default createComponent({
|
||||
}
|
||||
|
||||
let { value } = target;
|
||||
const { maxlength } = this.$attrs;
|
||||
const { maxlength } = this;
|
||||
|
||||
if (this.type === 'number' && isDef(maxlength) && value.length > maxlength) {
|
||||
if (isDef(maxlength) && value.length > maxlength) {
|
||||
value = value.slice(0, maxlength);
|
||||
target.value = value;
|
||||
}
|
||||
@ -264,10 +265,10 @@ export default createComponent({
|
||||
},
|
||||
|
||||
genWordLimit() {
|
||||
if (this.showWordLimit && this.$attrs.maxlength) {
|
||||
if (this.showWordLimit && this.maxlength) {
|
||||
return (
|
||||
<div class={bem('word-limit')}>
|
||||
{this.value.length}/{this.$attrs.maxlength}
|
||||
{this.value.length}/{this.maxlength}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user