React native react native actionsheet获取选定值
我正在使用react native actionsheet在iOS中显示下拉列表,我能够获取所选索引,但是,我不知道获取所选值的语法是什么React native react native actionsheet获取选定值,react-native,actionsheet,React Native,Actionsheet,我正在使用react native actionsheet在iOS中显示下拉列表,我能够获取所选索引,但是,我不知道获取所选值的语法是什么 showActionSheet = () => { this.ActionSheet.show() } handlePress = (buttonIndex, option) => { this.setState({ selected: buttonIndex, Region: options}) } <Text s
showActionSheet = () => {
this.ActionSheet.show()
}
handlePress = (buttonIndex, option) => {
this.setState({ selected: buttonIndex, Region: options})
}
<Text style={styles.inputfields} onPress={this.showActionSheet}>Region</Text>
<ActionSheet
ref={o => this.ActionSheet = o}
title={'Region'}
options={['North', 'South', 'East', 'West', 'Cancel']}
cancelButtonIndex={5}
selectedValue={this.state.Region}
value={this.state.Region}
onPress={this.handlePress}
/>
使用选项数组创建一个变量
const options = ['AUH', 'DXB', 'NE', 'WR', 'AAN', 'Cancel']
将该变量传递给ActionSheet组件
<ActionSheet
ref={o => (this.ActionSheet = o)}
title={"Region"}
options={options}
cancelButtonIndex={5}
selectedValue={this.state.Region}
value={this.state.Region}
onPress={this.handlePress}
/>;
希望这对你有帮助。请不要怀疑。我不太了解react native actionsheet,但我建立了 react native universal actionsheet更易于定制和控制 这里有一个例子
handlePress = buttonIndex => {
this.setState({
selected: buttonIndex,
Region: options[buttonIndex]
});
};