react-native的下拉列表Picker

xiaoxiao2021-02-27  379

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>
转载请注明原文地址: https://www.6miu.com/read-4104.html

最新回复(0)