大家好,我是贰妹子,希望我的博客对你有帮助(多动手练习一下呦)
将Swiper和Text通过一个View来封装.,要比自己画轮播图要方便许多,如果你需要自己写的轮播图,而不是第三方组件可以参照第二种方法
1⃣️、将Swiper和Text通过一个View来封装.、核心代码
<View style={
{height: 240}}>
<Swiper style={styles.wrapper}
height={240}
autoplay={true}
loop={true}
keyExtractor={(item, index) => index + ''}
index={1}
autoplayTimeout={3}
horizontal={true}
onMomentumScrollEnd={(e, state, context) => {
}}
dot={<View style={styles.dotSty}/>}
activeDot={<View style={styles.activeSty}/>}
paginationStyle={
{
bottom: 10
}}>
<View style={styles.slide}>
<Image style={
{width: ScreenWidth, height: 240}}
resizeMode="stretch"
source={
{uri: 'http://img004.hc360.cn/m7/M04/F0/C5/wKhQpFc1NVCEbmlVAAAAABk-c9Q712.jpg'}}>