本文主要是介绍RN的轮播图组件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
自行安装
yarn add react-native-swiper
示例代码
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;
效果图
这篇关于RN的轮播图组件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!