【发布时间】:2021-09-30 10:21:07
【问题描述】:
我有一个小问题。我正在使用以前使用两个选项的 ButtonGroup,但现在我提供了 4 个选项。
它在屏幕上正确呈现,但我只能选择前两个选项。如何在选择之间跳转,以便选择不同的按钮。
欢迎任何帮助!
<ButtonGroup
selectedIndex={this.state.test === "First" ? 0 : 1}
buttons={["First", "Second", "Third", "Fourth"]}
containerStyle={{ height: 50 }}
selectedButtonStyle={{ backgroundColor: "red" }}
selectedTextStyle={{ color: "white" }}
textStyle={{ fontSize: 18, fontWeight: '600' }}
onPress={(selectedIndex) =>
this.setState({
test: buttons[selectedIndex]
})}
/>
【问题讨论】:
标签: typescript react-native buttongroup