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-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>

View File

@ -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>
);
}