📜  防止 +,-,e 输入 ts - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:35.336000             🧑  作者: Mango

代码示例2
_keyUp(event: any) {
    const pattern = /[0-9\+\-\ ]/;
    let inputChar = String.fromCharCode(event.key);

    if (!pattern.test(inputChar)) {
      // invalid character, prevent input
      event.preventDefault();
    }
}