feat(Field): add show-word-limit prop (#4721)

This commit is contained in:
neverland
2019-10-14 20:39:39 +08:00
committed by GitHub
parent cd1e5d112a
commit 8ad1b13e18
7 changed files with 147 additions and 59 deletions
+12
View File
@@ -24,6 +24,7 @@ export default createComponent({
inputAlign: String,
errorMessage: String,
errorMessageAlign: String,
showWordLimit: Boolean,
type: {
type: String,
default: 'text'
@@ -260,6 +261,16 @@ export default createComponent({
</div>
);
}
},
renderWordLimit() {
if (this.showWordLimit && this.$attrs.maxlength) {
return (
<div class={bem('word-limit')}>
{this.value.length}/{this.$attrs.maxlength}
</div>
);
}
}
},
@@ -302,6 +313,7 @@ export default createComponent({
{this.renderRightIcon()}
{slots('button') && <div class={bem('button')}>{slots('button')}</div>}
</div>
{this.renderWordLimit()}
{this.errorMessage && (
<div class={bem('error-message', this.errorMessageAlign)}>
{this.errorMessage}