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 ...
随机推荐
- java web学习总结(十) -------------------HttpServletRequest对象
一.HttpServletRequest介绍 HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,通过这个对象 ...
- css之水平居中设置
行内元素: div,p{text-align:center;} 定宽块状元素: 第一宽度固定,第二margin-left和margin-right均是auto.div{border:1px ...
- 【grunt第三弹】grunt在前端实际项目中的应用
前言 [grunt第二弹]30分钟学会使用grunt打包前端代码(02) [grunt第一弹]30分钟学会使用grunt打包前端代码 经过前两次的学习,我们了解了grunt打包的一些基础知识,对于压缩 ...
- SharePoint 2013 Designer系列之自定义列表表单
在SharePoint的使用中,默认的样式过于单调经常困扰着我们,其实,SharePoint使用Designer工具,可以很轻松解决这一问题,制作出各式各样漂亮的页面.下面,让我们简单介绍下这一过程. ...
- ArcGIS中的坐标系统定义与投影转换【转】
ArcGIS中的坐标系统定义与投影转换 坐标系统是GIS数据重要的数学基础,用于表示地理要素.图像和观测结果的参照系统,坐标系统的定义能够保证地理数据在软件中正确的显示其位置.方向和距离,缺少坐标系统 ...
- Win7下共享WiFi热点方法
管理员权限运行CMD netsh wlan set hostednetwork mode=allow ssid=Wifi名称 key=Wifi密码 netsh wlan start hostednet ...
- Activity详解一 配置、启动和关闭activity
先看效果图: Android为我们提供了四种应组件,分别为Activity.Service.Broadcast receivers和Content providers,这些组建也就是我们开发一个And ...
- XML总结
1. XML 基本概念 扩展标记语言 (Extensible Markup Language, XML) ,用于标记电子文件使其具有结构性的标记语言,可以用来标记数据.定义数据类型,是一种允许用户对自 ...
- Java避免创建不必要的对象
小Alan最近看到了<Effective Java>这本书,这本书包含的内容非常丰富,这本书我就不多介绍了,只能默默的说一句,作为一名java开发错过了这本书难免会成为一个小遗憾,所以还是 ...
- Linux 通过sendmail 发邮件到外部邮箱
最近在写自动化巡检脚本,想着怎么预警后自动发送邮件报警. 首先下载最新版本mailx-12.4.tar.bz2 # wget http://sourceforge.net/projects/heirl ...