日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

利用keyup事件實現input框輸入0-1之間的數字且最多只能保留2位小數

作者:文仔醬醬醬 更新時間: 2023-07-24 編程語言
<Input ?type="tel" ?v-model="user.limitPricezk" style="width: 300px" ?placeholder="最低修改商品價格折扣"?maxlength='4' @on-keyup="restrictInp"></Input>
restrictInp(e){
?? ??? ??? ??? ? var reg = /^(0.\d+|0|1)$/;
?? ??? ??? ??? ? ? ?if (reg.test(e.target.value)) {
?? ??? ??? ??? ? ? ? ? ?this.user.limitPricezk = e.target.value;
?? ??? ??? ??? ? ? ?} else {
?? ??? ??? ??? ? ? ? ? ?if (e.target.value != "0.")
?? ??? ??? ??? ? ? ? ? ?this.user.limitPricezk = "";
?? ??? ??? ??? ? ? ?}
?? ??? ??? ?},

注意一個問題 設置input屬性為number時maxlength不生效,將屬性設置為tel

原文鏈接:https://blog.csdn.net/baidu_41899377/article/details/125146378

  • 上一篇:沒有了
  • 下一篇:沒有了
欄目分類
最近更新