【发布时间】:2022-01-29 17:39:56
【问题描述】:
我正在使用 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,
},
});
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));
}
}
请让我知道问题任何帮助将不胜感激。
【问题讨论】:
-
嘿,您找到解决方案了吗?我在父视图中添加了 zindex 来解决这个问题,但最终出现了另一个问题。现在我无法从列表中选择任何内容。
-
@Reema 是的,如果您阅读了它提到的文档,父容器中的 zIndex 可能会导致此类问题,请使用下拉选择器的样式属性来获取您想要的任何样式,这已解决了我的问题
标签: reactjs react-native react-native-android react-native-ios