vue中監聽input只能輸入數字及英文或者其他情況
阿新 • • 發佈:2019-01-26
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> (只能輸入數字,英文及中文)
2.
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,'');
}
},