例如如下代碼:<input type="text" v-model="sellPrice"><input type="text" v-model="buyVolume">reg:/^[0-9]+(.[0-9]{1,8})?$/ reg1:/[0-9]d*/watch:{ buyPrice:function(){
}, sellPrice:function(){ let a = this.sellPrice; this.sellPrice = a.match(this.reg,'');
}, buyVolume:function(){ this.buyVolume = this.buyVolume.match(/[0-9]\d*/,'');
}, sellVolume:function(){ this.sellVolume = this.sellVolume.match(/[0-9]\d*/,'');
}
}Price無法成功。為什么sellVolume能成功但是會報this.sellVolume.match is not a function
2 回答

慕的地10843
TA貢獻1785條經驗 獲得超8個贊
match得到的是個數組所以報錯而且正則應該是/^[0-9]d$|(^[0-9]+.[0-9]{0,8})/,watch檢測數據是沒問題的。用computed反而會麻煩一些
添加回答
舉報
0/150
提交
取消