无法从 react-native-dropdown-picker 中选择项目

TRI*_*URI 4 reactjs react-native react-native-android react-native-ios

我正在使用 React-native-dropdown-picker,但是我无法从下拉列表中选择任何项目,这些项目被下面的视图重叠。我试过添加 position:'absolute, zIndex:2 但仍然是 itemlist 重叠如下: 在此处输入图片说明

我已经编写了下拉组件的代码如下

 return (
    <View>
      <View style={styles.container}>
        {console.log('new array', dateArr)}
        {console.log('arr', arr)}
        <Icon
          name="arrow-left"
          size={20}
          color="#fff"
          style={{marginTop: 12}}
        />
        {console.log('----------date', dateArr)}
        {dateArr != null && (
          <DropDownPicker
            onValueChange={(value) => onValSelect(value)}
            items={dateArr}
            itemStyle={{
              // justifyContent: 'flex-start',
              flexDirection:'row'
            }}
            
            containerStyle={{height: 40,width:'80%',zIndex:2}}
          />
        )}
       
      </View>
      <DaysInAWeek daysInAWeek={daysInAWeek} />
    </View>
  );
}
const styles = StyleSheet.create({
  container: {
    backgroundColor: '#FE017E',
    // height: 56,
    width: '100%',
    flexDirection: 'row',
    padding: 10,
  },
});
Run Code Online (Sandbox Code Playgroud)

onValSelect() 如下:

 function onValSelect(val) {
    if (val.length > 1) {
      let arr = [];
      for (let i = val[0]; i <= val[1]; i += 86400000) {
        let date = getMonthDate(new Date(i));
        arr.push(date);
      }

      console.log('final arr', arr);
      setDaysInAWeek(arr);
    } else {
      console.log('single date', new Date(val));
      setDaysInAWeek(new Date(val));
    }
  }
Run Code Online (Sandbox Code Playgroud)

请让我知道这个问题,任何帮助将不胜感激。

DEE*_*PAK 5

如果有人仍然没有得到这个,我发现这里有一些东西这都与父元素有关,所以如果 DropDownPicker 组件没有具有一定高度的父元素,那么即使您看到选项,也不会让您选择。

只需提供父元素minHeight:300px或您想要的任何高度示例 -

<View style={{minHeight: 300}}>
          
             <DropDownPicker
               items={timeslots}
               defaultValue={this.state.selected2}
               containerStyle={{height: 40}}
               style={{backgroundColor: '#fafafa'}}
               itemStyle={{
                 justifyContent: 'flex-start',
               }}
               dropDownStyle={{backgroundColor: '#fafafa'}}
               onChangeItem={(item) => 
                 this.setState({
                   selected2: item.value,
                 });
               }
             />
        
         </View>

Run Code Online (Sandbox Code Playgroud)