vue实现限制input只能输入中文
input增加参数@keyup.native="inputChange($event)" @keydown.native="inputChange($event)"增加方法inputChange(event) {const val = event.target;val.value = val.value.replace(/[^\u4E00-\u9FA5]/g, '');this.name = va
·
input增加参数
@keyup.native="inputChange($event)" @keydown.native="inputChange($event)"
增加方法
inputChange(event) {
const val = event.target;
val.value = val.value.replace(/[^\u4E00-\u9FA5]/g, '');
this.name = val.value;
},
源代码:
<el-input v-model="formValue.supplier.name"
@keyup.native="inputChange($event)"
@keydown.native="inputChange($event)">
</el-input>
inputChange(event) {
const val = event.target;
val.value = val.value.replace(/[^\u4E00-\u9FA5]/g, '');
this.formValue.supplier.name = val.value;
},
更多推荐
已为社区贡献1条内容
所有评论(0)