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 = 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;
},

你可能感兴趣的:(前端,js,vue,input,elementui)