1.<input placeholder="请输入条形码" class="disPriceStyle" v-model = 'searcBarCode'></input>、 (只能输入数字,英文)
<input placeholder="请输入商品条形码" class="disPriceStyle" maxlength="20" v-model = 'searchGoodsName'></input> (只能输入数字,英文及中文)
<input placeholder="请输入活动名称" class="disPriceStyle" maxlength="20" v-model="searchProName"></input> (只能输入数字,英文及中文)
watch:{
searcBarCode:function(){
this.searcBarCode=this.searcBarCode.replace(/[\W]/g,'');
},
searchGoodsName:function(){
this.searchGoodsName = this.searchGoodsName.replace(/[^A-Za-z0-9\u4e00-\u9fa5]/g,'');
},
searchProName:function(){
this.searchProName = this.searchProName.replace(/[^A-Za-z0-9\u4e00-\u9fa5]/g,'');
}
},
注意 :如果没有实时更改数据需要加上(例子)
this.$nextTick(() => {
this.cardNum = this.cardNum.replace(/[\W]/g, '');
})