只能输入汉字:
<el-input maxlength="10" class="input" style="margin-left: 680px"
placeholder="资产名称" v-model.trim="inputName"
onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')"
@blur="inputName = $event.target.value"
></el-input>
注意:输入汉字必须要用onkeyup,否则会出现只能输入一个汉字的情况
只能输入大于零的小数:
//if判断输入第一位为小数点时,自动在前面添加0
<el-input maxlength="10" class="input" placeholder="价格"
oninput="if(value.length === 1 && value === '.') { value = '0.'; }
else { value = value.replace(/[^\d.]/g,'').replace(/^(\d*\.\d*).*$/,'$1'); }"
v-model.trim="inputPrice">
</el-input>
注意:输入数字必须要用oninput,否则输入框内容replace不完全