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;

效果图

相关推荐
小满zs几秒前
Next.js精通SEO第三章(TDK + OG)
前端·seo
张风捷特烈1 小时前
状态管理大乱斗#03 | Provider 源码全面评析
android·前端·flutter
灵感__idea7 小时前
Hello 算法:“走一步看一步”的智慧
前端·javascript·算法
吴文周8 小时前
告别重复劳动:一套插件让 AI 替你写代码、修Bug、做测试、上生产
前端·后端·ai编程
Mh9 小时前
我决定写一个 3D 地球仪来记录下我要去的地方
前端·javascript·动效
yaoxin5211239 小时前
390. Java IO API - WatchDir 示例
java·前端·python
懒狗小前端9 小时前
做了一个 codex 的中文文档网站,做的不好可以随便喷
前端·后端
. . . . .10 小时前
ref、useRef 和 forwardRef
前端·javascript·react.js
energy_DT11 小时前
2026年海上钻井平台数字孪生平台:引领海洋能源数字化转型
前端
Eric_见嘉11 小时前
在职前端 Agent 配置分享
前端·后端·agent