ReactNative新手学习之路04 组件化开发轮播图swiper支持安卓和IOS
react native 新手之路04 组件化开发轮播图swiper支持安卓和IOS
npm install react-native-carousel --save git 地址Properties
hideIndicators={false} // Set to true to hide the indicatorsindicatorColor="#FFFFFF" // Active indicator color
indicatorSize={20} // Indicator bullet sizeindicatorSpace={15} // space between each indicatorinactiveIndicatorColor="#999999" // Inactive indicator color
indicatorAtBottom={true} // Set to false to show the indicators at the topindicatorOffset={250} // Indicator relative position from top or bottomonPageChange={callback} // Called when the active page changes
animate={true} // Enable carousel autoplaydelay={1000} // Set Animation delay between slidesloop={true} // Allow infinite looped animation. Depends on Prop {...animate} set to true.新建Swiper.js 创建组件
'use strict';
var React = require('react-native');var Carousel = require('react-native-carousel');
var {AppRegistry,
StyleSheet,
Text,
View,
Image,
} = React;
var Swiper = React.createClass({render: function() {
return (
<Carousel width={this.props.dwidth} indicatorAtBottom={false} indicatorOffset={110} indicatorSize={20} indicatorSpace={16} delay={3000} ><View style={styles.swipeContainer}><Image
style={styles.image}resizeMode={Image.resizeMode.stretch}source={{uri: this.props.data[0],width:this.props.dwidth}}/></View>
<View style={styles.swipeContainer}><Image
style={styles.image}resizeMode={Image.resizeMode.stretch}source={{uri: this.props.data[1],width:this.props.dwidth}}/></View>
<View style={styles.swipeContainer}><Image
style={styles.image}resizeMode={Image.resizeMode.stretch}source={{uri: this.props.data[2],width:this.props.dwidth}}/></View>
</Carousel>
);
}
});
const styles = StyleSheet.create({
swipeContainer: {alignItems: 'center',
backgroundColor: 'transparent',
},
image:{height:128,
}
});
module.exports = Swiper;
使用刚刚创建的组件
render() {var {height, width} = Dimensions.get('window');//适应各种尺寸return (
<View style={styles.container}><View style={{ height:128,}}><Swiper data={sliderImgs} dwidth={width} ></Swiper></View>
<View style={{ height:128,backgroundColor:'white'}}><ToolsBar bardata={this.state.toolsdata} ></ToolsBar></View>
<View style={{ height:120,backgroundColor:'white'}}></View>
</View>
);
}
React Native 技术交流群127482131,欢迎大家一起来学习RN。
转载请保留文章链接 http://www.reactnative.pw/
ReactNative新手学习之路04 组件化开发轮播图swiper支持安卓和IOS的更多相关文章
- 前端笔记之JavaScript面向对象(四)组件化开发&轮播图|俄罗斯方块实战
一.组件化开发 1.1组件化概述 页面特效的制作,特别需要HTML.CSS有固定的布局,所以说现在越来越流行组件开发的模式,就是用JS写一个类,当你实例化这个类的时候,页面上的效果布局也能自动完成. ...
- ReactNative新手学习之路07ListView_ renderHeader使用StaticContainer
react native新手学习之路07ListView_ renderHeader使用StaticContainer 1.某些特殊场景需要用ScrollView滚动和ListView配合但是不幸运的 ...
- ReactNative新手学习之路01-创建项目开始
新手学习之路01-创建项目开始 小菜鸟准备学习RN开发,决定写下自己的学习历程,方便其他也想要学习RN的人,后期会持续更新写下自己所有学习经历,一步步从菜鸟成长成业内高手.开发环境准备,本文默认环境已 ...
- React Native 之轮播图swiper组件
注释:swiper组件是第三方组件 所以在使用之前应该先在命令行安装,然后将第三方的模块引入(第三方模块地址:https://github.com/leecade/react-native-swipe ...
- ReactNative新手学习之路03真机调试
React Native新手入门03真机调试(iOS) 从设备访问开发服务器 在启用开发服务器的情况下,你可以快速的迭代修改应用,然后在设备上查看结果.这样做的前提是你的电脑和设备必须在同一个wifi ...
- ReactNative新手学习之路02第一个RN项目
开始第一个RN项目(iOS版)我的电影列表0.1版,后面做列表版 打开上一节项目 index.ios.js,android打开index.android.js.我这里使用的是Atom编辑器,你也可以使 ...
- ReactNative新手学习之路06滚动更新ListView数据的小示例
本节带领大家学习使用ListView 做一个常用的滚动更新数据示例: 知识点: initialListSize={200} 第一次加载多少数据行 onEndReached={this.onEndRea ...
- ReactNative新手学习之路05 使用夜神模拟器调试ReactNative
1.首先确保adb环境添加到path环境 2.安装好夜神模拟器 3.运行模拟器 4.adb connect 127.0.0.1:62001 5.摇一摇设置IP和端口 如127.168. ...
- 阶段5 3.微服务项目【学成在线】_day04 页面静态化_13-页面静态化-数据模型-轮播图DataUrl接口
要开发轮播图的DataUrl的接口 轮播图的配置的集合 xc-framework-model这个module下 CmsConfigModel的类的属性 定义接口 在api里面定义接口:CmsConfi ...
随机推荐
- (原) 2.1 Zookeeper原生API使用
本文为原创文章,转载请注明出处,谢谢 Zookeeper原生API使用 1.jar包引入,演示版本为3.4.6,非maven项目,可以下载jar包导入到项目中 <dependency> & ...
- Javascript中addEventListener和attachEvent的区别
在利用javascript为DOM Element添加事件处理程序时,如果要想下兼容IE6,7时,就不得不考虑addEventListener与attachEvent的异同. 1.首先说下addEve ...
- jquery叠加页片自动切换特效
查看效果:http://keleyi.com/keleyi/phtml/jqtexiao/34.htm 下面是HTML代码: <!DOCTYPE html> <html xmlns= ...
- 【模块化编程】理解requireJS-实现一个简单的模块加载器
在前文中我们不止一次强调过模块化编程的重要性,以及其可以解决的问题: ① 解决单文件变量命名冲突问题 ② 解决前端多人协作问题 ③ 解决文件依赖问题 ④ 按需加载(这个说法其实很假了) ⑤ ..... ...
- jquery attr()方法
在JS中设置节点的属性与属性值用到setAttribute(),获得节点的属性与属性值用到getAttribute(),而在jquery中,用一个attr()就可以全部搞定了,赞一个先 ^^ jque ...
- Linux安全基础:sed命令的使用
sed 是一个很好的文件处理工具,本身是一个管道命令,主要是以行为单位进行处理,可以将数据行进行替换.删除.新增.选取等特定工作. Sed本质上是一个编辑器,但是它是非交互式的,这点与VIM不同:同时 ...
- FMDB基本使用
1.打开数据库 #import "ViewController.h" #import "FMDB.h" @interface ViewController () ...
- nginx File not found
出现 nginx File not found 错误 首先判断这个文件是否 真的存在 如果文件确实存在 那么应该是 php-fpm 路径有问题了 解决办法 1查看 php-fpm 的配置文件 我的 文 ...
- MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems
早晨宁波那边的IT人员打电话告知数据库无法访问了.其实我在早晨也发现Ignite监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...
- 从零自学Hadoop(08):第一个MapReduce
阅读目录 序 数据准备 wordcount Yarn 新建MapReduce 示例下载 系列索引 本文版权归mephisto和博客园共有,欢迎转载,但须保留此段声明,并给出原文链接,谢谢合作. 文章是 ...