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 ...
随机推荐
- SpringMVC基本使用
springMVC是一个MVC框架,他控制着请求相应的整个流程,从请求一进入到应用服务器到相应离开,都离不开mvc框架 请求在应用服务器中 先说说请求相应在应用服务器的整个过程 DisptacherS ...
- e.target.files[0]层层剖析
因为我现在拿到的一个功能是上传时过滤掉很大尺寸的图片,所以需要来拿到上传时选择图片的size,所以有了这篇博文 不多说 上代码 $('input').change(function(e){ 1️⃣.c ...
- CSS3与页面布局学习笔记(六)——CSS3新特性(阴影、动画、渐变、变形( transform)、透明、伪元素等)
一.阴影 1.1.文字阴影 text-shadow<length>①: 第1个长度值用来设置对象的阴影水平偏移值.可以为负值 <length>②: 第2个长度值用来设置对象的阴 ...
- 基本排序算法——shell排序java实现
shell排序是对插入排序的一种改进. package basic.sort; import java.util.Arrays; import java.util.Random; public cla ...
- Atitit.常见软件 数据 交换格式 标准
Atitit.常见软件 数据 交换格式 标准 1. 常见的数据格式txt ,doc ,pic,music ,vodio1 2. 通用格式json yaml phpstr1 3. 专用格式1 4. 用户 ...
- 点(x3,y3)到经过点(x1,y1)和点(x2,y2)的直线的最短距离
/// <summary> /// 点(x3,y3)到经过点(x1,y1)和点(x2,y2)的直线的最短距离 /// </summary> /// <param name ...
- iOS点击推送消息跳到应用指定页面
现在的推送用的越来越频繁,几乎每个应用都开始用到了.其实又有几个用户会去看推送消息呢?没办法,产品经理最大啊,只是苦了我们这一帮程序员啊!闲话少说,进入正题.兄弟我用的是极光推送,自然是以极光推送为例 ...
- Android studio 使用Gradle发布Android开源项目到JCenter 总结
1.注册账号 先到https://bintray.com注册一个账号. 这个网站支持 github 账户直接登录的 2.获取 bintray.user 和 bintray.apikey ...
- IOS开发基础知识--碎片3
十二:判断设备 //设备名称 return [UIDevice currentDevice].name; //设备型号,只可得到是何设备,无法得到是第几代设备 return [UIDevice cur ...
- IOS开发之支付功能概述
前言:本随笔将对IOS开发的支付功能进行一个概述. 内容大纲: 一.常见的支付方案简介 二.第三方支付SDK 三.苹果官方支付方案 四.Web支付方案 正文: 一.常见的支付方案简介 在微信支付中 微 ...