亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue.js對于input輸入的內容如何使用正則表達式進行判斷

vue.js對于input輸入的內容如何使用正則表達式進行判斷

森欄 2018-08-23 20:49:12
例如如下代碼:<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反而會麻煩一些

查看完整回答
反對 回復 2018-08-26
  • 2 回答
  • 0 關注
  • 7786 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號