react-native 轮播图 ——react-native-swiper使用
来源:互联网 发布:东盟水果进口贸易数据 编辑:程序博客网 时间:2024/05/19 23:00
今天学习了轮播图的使用,上网查阅了一下,发现有react-native-swiper和React-Native-Viewpager 两种封装的比较好的第三方组件,对比了下文档,觉得react-native-swiper功能更加完善,而且文档说明比较全面,所以只用了react-native-swiper,下面介绍下react-native-swiper的使用。该组件同时支持android和iOS。
react-native-swiper的github地址
使用说明:
1. 先安装React-native-swiper
使用说明:
1. 先安装React-native-swiper
npm i react-native-swiper –save
2. 导入Swiper
import Swiper from ‘react-native-swiper’;
- 使用 Swiper
<Swiper style={styles.swiper} height={200} horizontal={true} paginationStyle={{bottom: 10}} showsButtons={false}> <Image source={require('./js/img/a.jpg')} style={styles.img}/> <Image source={require('./js/img/b.jpg')} style={styles.img}/> <Image source={require('./js/img/c.jpg')} style={styles.img}/></Swiper>const styles = StyleSheet.create({ swiper: {}, img: { width: dimensions.width, height: 200, }});
4.相关属性和方法介绍
先看个事例:
<Swiper style={styles.swiper} //样式 height={200} //组件高度 loop={true} //如果设置为false,那么滑动到最后一张时,再次滑动将不会滑到第一张图片。 autoplay={true} //自动轮播
autoplayTimeout={4} //每隔4秒切换 horizontal={true} //水平方向,为false可设置为竖直方向 paginationStyle={{bottom: 10}} //小圆点的位置:距离底部10px showsButtons={false} //为false时不显示控制按钮 showsPagination={false} //为false不显示下方圆点 dot={<View style={{ //未选中的圆点样式 backgroundColor: 'rgba(0,0,0,.2)', width: 18, height: 18, borderRadius: 4, marginLeft: 10, marginRight: 9, marginTop: 9, marginBottom: 9,}}/>} activeDot={<View style={{ //选中的圆点样式 backgroundColor: '#007aff', width: 18, height: 18, borderRadius: 4, marginLeft: 10, marginRight: 9, marginTop: 9, marginBottom: 9,}}/>}> <Image source={require('./js/img/a.jpg')} style={styles.img}/> <Image source={require('./js/img/b.jpg')} style={styles.img}/> <Image source={require('./js/img/c.jpg')} style={styles.img}/></Swiper>
阅读全文
0 0
- react-native 轮播图 ——react-native-swiper使用
- react native学习笔记11——react-native-swiper轮播图
- React-Native学习--轮播图第三方组件-react-native-swiper
- React-Native学习--轮播图第三方组件-react-native-swiper
- React-Native-swiper React Native 轮播类组件
- React Native 如何做轮播图 react-native-swiper
- react-native使用Swiper在安卓上不显示
- react-native-swiper 轮播类组件
- react-native react-native-swiper 设置horizontal=false无效
- React Native——react-navigation的使用
- React Native——react-navigation的使用
- 基于react-native-swiper 封装的bannerView
- react-native-swiper 让人无语的坑
- react-native安装使用
- react-native使用flux
- 开始使用React Native
- React Native Button使用
- React Native 属性使用
- zabbix中文乱码解决方案
- python中的import,reload以及__import__
- R语言数据挖掘之关联规则
- Linux 静态库与动态库搜索路径设置详解
- django static_root static_url media_root mdia_url详解
- react-native 轮播图 ——react-native-swiper使用
- C++学习:引用和函数的高级用法
- Mybatis--Statement Builders
- VMvare拷贝后提示路径错误(无法打开xxxx文件)
- lintcode-矩阵面积
- 【CountDownLatch实例】主线程等待其它线程执行完毕
- 生成1-256十进制,二进制,八进制,十六进制值
- JQuery
- c++ 解析从浏览器端传过来的图像base64编码,并转换成opencv识别的格式