自行安装
js
yarn add react-native-swiper
示例代码
js
import React, {useRef, useEffect} from 'react';
import {View, Text} from 'react-native';
import Swiper from 'react-native-swiper';
const MySwiper = () => {
return (
<Swiper autoplay={true}>
{/* 设置 autoplay 为 false,关闭自动播放 */}
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text>Slide 1</Text>
</View>
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text>Slide 2</Text>
</View>
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Text>Slide 3</Text>
</View>
</Swiper>
);
};
export default MySwiper;
效果图