<TextInput>
组件具有一个textContentType
字段,可让您自动填充某些字段,例如姓名,电子邮件,电话等。我似乎无法自动填充电话号码,我错过了什么吗?
<TextInput
autoFocus
blurOnSubmit={false}
editable={!loading}
placeholder="Enter phone number"
textContentType="telephoneNumber"
dataDetectorTypes="phoneNumber"
maxLength={100}
keyboardType="phone-pad"
value={phone}
/>
RN版本为0.55
答案 0 :(得分:0)
如果您在Mac上的仿真器上运行,则不会显示该关键字,但是您可以使用它。尝试在真实设备上运行它!
请查看此小吃:@abranhe/stackoverflow-56691969
源代码:
import React, { Component } from 'react';
import { View, StyleSheet, TextInput } from 'react-native';
export default class App extends Component {
state: {
phone: '',
};
render() {
return (
<View style={styles.container}>
<TextInput
autoFocus
blurOnSubmit={false}
placeholder="Enter phone number"
textContentType="telephoneNumber"
dataDetectorTypes="phoneNumber"
maxLength={100}
keyboardType="phone-pad"
onChangeText={phone => this.setState({ phone })}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
marginTop: 50,
},
});