我正在使用下面的代码使用react-native-multiple-select创建一个多选下拉列表。
onSelectedItemsChange = selectedItems => {
this.setState({ selectedItems });
};
render() {
return (
<View style={{ flex: 1 }}>
<MultiSelect
hideTags
items={items}
uniqueKey="num"
ref={(component) => { this.multiSelect = component }}
onSelectedItemsChange={this.onSelectedItemsChange}
selectedItems={selectedItems}
selectText="Pick Items"
searchInputPlaceholderText="Search Items..."
tagRemoveIconColor="#CCC"
tagBorderColor="#CCC"
tagTextColor="#CCC"
selectedItemTextColor="#CCC"
selectedItemIconColor="#CCC"
itemTextColor="#000"
displayKey="gas"
searchInputStyle={{ color: '#CCC' }}
submitButtonColor="#CCC"
submitButtonText="Submit"
/>
<View>
我的数组如下:
data = [
{gas:H2, num: 0},
{gas:CO2, num: 1}
]
当我选择前三个项目时,我的selectItems数组是
[0,1]
它应该显示我选择的数组索引,应该是
[0,1,2]
我在做什么错了?