1.导入项目组件
import {
Picker,
} from
'react-native';
2.初始化属性:
3.实现代码如下:
<View>
<Text>
Picker
选择器实例
</Text>
<Picker
mode={
'dropdown'}
style={styles.picker}
selectedValue={
this.state.language}
onValueChange={(value) =>
this.setState({language: value})}>
<Picker.Item label=
"Java" value=
"java" />
<Picker.Item label=
"JavaScript" value=
"javaScript" />
</Picker>
<Text>
当前选择的是:{
this.state.language}</Text>
</View>