📜  输入将仅获得数字 vue - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:26.455000             🧑  作者: Mango

代码示例2


onlyNumber ($event) {
   //console.log($event.keyCode); //keyCodes value
   let keyCode = ($event.keyCode ? $event.keyCode : $event.which);
   if ((keyCode < 48 || keyCode > 57) && keyCode !== 46) { // 46 is dot
      $event.preventDefault();
   }
}