图像滑块或 Swiper 工作,它仅在使用指针向左或向右完成时才会滑动,但:autoplay ={true}
不会自动滑动滑块。
它仅适用于此处 (npmjs.com)的示例,使用View
和Text
因此,我尝试将 a 添加View
为容器,但没有成功:
<View style ={{height:200}}>
<Swiper autoplay ={true}>
{this.state.dataBanner?.length > 0 && this.state.dataBanner.map((itemImg)=> {
return (
//<View> ADD VIEW -> FAILED ATTEMPT
<ImageBackground
source ={{ uri: itemImg.urlToImage }}
style ={{height:"100%", width:"100%"}}
>
<LinearGradient style={styles.bgBanner} colors={[ 'transparent', 'black']} >
<Text style={styles.textBanner} numberOfLines={2}>{itemImg.title}</Text>
</LinearGradient>
</ImageBackground>
//</View> ADD VIEW -> FAILED ATTEMPT
)
})}
</Swiper>
</View>
如何使滑块在 ImageBackground 中自动工作?