fix(Field): incorrect count of line break in safari (#5049)

This commit is contained in:
neverland 2019-11-19 21:06:19 +08:00 committed by GitHub
parent f8c130d0cb
commit 1c03d5d3f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 13 deletions

View File

@ -2,10 +2,7 @@
<demo-section> <demo-section>
<demo-block :title="$t('basicUsage')"> <demo-block :title="$t('basicUsage')">
<van-cell-group> <van-cell-group>
<van-field <van-field v-model="value" :placeholder="$t('usernamePlaceholder')" />
v-model="value"
:placeholder="$t('usernamePlaceholder')"
/>
</van-cell-group> </van-cell-group>
</demo-block> </demo-block>
@ -69,10 +66,7 @@
:placeholder="$t('smsPlaceholder')" :placeholder="$t('smsPlaceholder')"
> >
<template #button> <template #button>
<van-button <van-button size="small" type="primary">
size="small"
type="primary"
>
{{ $t('sendSMS') }} {{ $t('sendSMS') }}
</van-button> </van-button>
</template> </template>

View File

@ -18,8 +18,9 @@ export default createComponent({
leftIcon: String, leftIcon: String,
rightIcon: String, rightIcon: String,
clearable: Boolean, clearable: Boolean,
labelClass: null, maxlength: [Number, String],
labelWidth: [Number, String], labelWidth: [Number, String],
labelClass: null,
labelAlign: String, labelAlign: String,
inputAlign: String, inputAlign: String,
errorMessage: String, errorMessage: String,
@ -101,9 +102,9 @@ export default createComponent({
} }
let { value } = target; 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); value = value.slice(0, maxlength);
target.value = value; target.value = value;
} }
@ -264,10 +265,10 @@ export default createComponent({
}, },
genWordLimit() { genWordLimit() {
if (this.showWordLimit && this.$attrs.maxlength) { if (this.showWordLimit && this.maxlength) {
return ( return (
<div class={bem('word-limit')}> <div class={bem('word-limit')}>
{this.value.length}/{this.$attrs.maxlength} {this.value.length}/{this.maxlength}
</div> </div>
); );
} }