代码:
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(text) => {
const newText = text.replace(/[^\d]+/, '');
this.setState({inputValue: newText})
}}
value={this.state.inputValue}
keyboardType='numeric'
/>
我希望用户只能输入数字,其他将被替换。 但实际上没有效果。
ios> 10
“反应”:“ 16.3.1”,
“ react-native”:“ ^ 0.55.3”,