tips:解决了e.target中输入中文 会把拼音也输入的情况
1 html
<FormItem label="角色名称" prop="roleName"> <Input v-model="formInfoData.roleName" placeholder="请输入角色名称" maxlength="20" @on-keyup="btKeyUp(‘roleName‘)" @on-keydown="btKeyDown(‘roleName‘)"/></FormItem> 2 vue
//只能输入汉字英文数字btKeyDown(name) { this.formInfoData[name] = this.formInfoData[name].replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]\_/g,"");},//控制不能输入特殊字符btKeyUp(name) { this.formInfoData[name]= this.formInfoData[name].replace(/[`[email protected]#$%^&*()\-+=<>?:"{}|,.\/;‘\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/g,"");},
原文地址:https://www.cnblogs.com/supershare/p/11958030.html
时间: 2025-01-15 02:40:20