vue input限制只能输入数字

时间:2020-03-05 21:52:28   收藏:0   阅读:1487
 
<input class="wd50"   @keydown="handleInput"  />
 
handleInput(e) {
      let a = e.key.replace(/[^\d]/g, "");
      if (!a && e.keyCode !== 8) {
        e.preventDefault();
      }
  }

原文:https://www.cnblogs.com/geekjsp/p/12422798.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!