我需要在我的应用程序上使用数字键盘,但在某些智能手机中,数字键盘没有逗号或点号,对此有任何解决方法吗?还是要避免其他事情?
代码:我正在使用Native-Base,但是即使没有它,结果也是一样的
class CampoFloat extends Component {
render() {
const { ...props } = this.props;
return (
<View>
<Item floatingLabel style={styles.Item}>
<Label style={{
color: '#323232',
fontSize: 18,
marginTop: 5
}}>{this.props.titulo}</Label>
<Input
style={styles.input}
{...props}
/>
</Item>
</View>
);
}
}
<CampoFloat
titulo="Preço do produto:"
autoCorrect={false}
keyboardType="numeric"
onChangeText={(event) => this.setState({ preco: event })}
/>
最佳答案
根据facebook文档ReactNative具有适用于Android的键盘类型,请尝试使用
<TextInput
key={phone ? 'input-phone' : 'input-default'}
keyboardType={phone ? 'phone-pad' : 'default'}
/>