提交 33edaa70 编写于 作者: D dolymood

chore(demo): add input max length demo

上级 020481c9
......@@ -25,6 +25,10 @@
<switch-option class="item" name="readonly" :value="readonly"
@update:value="updateReadonly"></switch-option>
</div>
<div class="group">
<switch-option class="item" name="maxlength:10" :value="maxlength10"
@update:value="updateMaxLength"></switch-option>
</div>
<div class="group">
<switch-option class="item" name="clearable" :value="useClear"
@update:value="updateUseClear"></switch-option>
......@@ -58,6 +62,7 @@
value: '',
disabled: false,
useClear: true,
maxlength10: false,
clearBlurHidden: true,
readonly: false,
isPwd: true,
......@@ -84,6 +89,16 @@
}
}
},
watch: {
value(newV) {
if (this.maxlength10 && newV.length > 10) {
newV = newV.slice(0, 10)
this.$nextTick(() => {
this.value = newV
})
}
}
},
methods: {
updateDisabled(val) {
this.disabled = val
......@@ -97,6 +112,9 @@
updateBlurHidden(val) {
this.clearBlurHidden = val
},
updateMaxLength(val) {
this.maxlength10 = val
},
updatePwd(val) {
this.isPwd = val
this.type = this.isPwd ? 'password' : 'text'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册