RN的轮播图组件

自行安装

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;

效果图

相关推荐
万物得其道者成2 小时前
前端大整数精度丢失:一次踩坑后的实战解决方案(`json-bigint`)
前端·json
鹏北海3 小时前
移动端 H5 响应式字体适配方案完全指南
前端
柳杉4 小时前
使用AI从零打造炫酷医疗数据可视化大屏,源码免费拿!
前端·javascript·数据可视化
凌云拓界4 小时前
前端开发的“平衡木”:在取舍之间找到最优解
前端·性能优化·架构·前端框架·代码规范·设计规范
zhengfei6115 小时前
【XSS payload 】一个经典的XSS payload
前端·xss
全栈老石6 小时前
手写一个无限画布 #1:坐标系的谎言
前端·canvas
XW01059996 小时前
4-11判断素数
前端·python·算法·素数
J2虾虾6 小时前
Spring Boot中使用@Scheduled做定时任务
java·前端·spring boot
Heo6 小时前
深入React19任务调度器Scheduler
前端·javascript·面试
一枚前端小姐姐7 小时前
Vue3 + Pinia 状态管理,从入门到模块化
前端·vue.js