如何在数字键盘类型中隐藏点和破折号反应本机

How to hide point and dash in numeric keyboardType react native

我是 react-native 的新手。我正在使用数字键盘类型:

<TextInput style={styles.TextInputSecond} editable = {true} maxLength={3} keyboardType="numeric" ></TextInput>

它也在键盘上显示 .-

如何从键盘隐藏或禁用它们(如 , 禁用)?

你能试试这个并检查它是否解决了你的问题

keyboardType={Device.isAndroid ? "numeric" : "number-pad"}

或者您也可以添加

const onlyNumber = number.replace(/[^0-9]/g, "");

this.setState({
  onlyNumber
});

TextInput 的属性值

value={this.state.onlyNumber}