react native 新手之路04 组件化开发轮播图swiper支持安卓和IOS

  1. npm install react-native-carousel --save git 地址Properties

     
     
     
     
     
    hideIndicators={false} // Set to true to hide the indicators
    indicatorColor="#FFFFFF" // Active indicator color
    indicatorSize={20} // Indicator bullet size
    indicatorSpace={15} // space between each indicator
    inactiveIndicatorColor="#999999" // Inactive indicator color
    indicatorAtBottom={true} // Set to false to show the indicators at the top
    indicatorOffset={250} // Indicator relative position from top or bottom
    onPageChange={callback} // Called when the active page changes
    animate={true} // Enable carousel autoplay
    delay={1000} // Set Animation delay between slides
    loop={true} // Allow infinite looped animation. Depends on Prop {...animate} set to true.
     
  2. 新建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;
     
  3. 使用刚刚创建的组件

     
     
     
     
     
      
    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的更多相关文章

  1. 前端笔记之JavaScript面向对象(四)组件化开发&轮播图|俄罗斯方块实战

    一.组件化开发 1.1组件化概述 页面特效的制作,特别需要HTML.CSS有固定的布局,所以说现在越来越流行组件开发的模式,就是用JS写一个类,当你实例化这个类的时候,页面上的效果布局也能自动完成. ...

  2. ReactNative新手学习之路07ListView_ renderHeader使用StaticContainer

    react native新手学习之路07ListView_ renderHeader使用StaticContainer 1.某些特殊场景需要用ScrollView滚动和ListView配合但是不幸运的 ...

  3. ReactNative新手学习之路01-创建项目开始

    新手学习之路01-创建项目开始 小菜鸟准备学习RN开发,决定写下自己的学习历程,方便其他也想要学习RN的人,后期会持续更新写下自己所有学习经历,一步步从菜鸟成长成业内高手.开发环境准备,本文默认环境已 ...

  4. React Native 之轮播图swiper组件

    注释:swiper组件是第三方组件 所以在使用之前应该先在命令行安装,然后将第三方的模块引入(第三方模块地址:https://github.com/leecade/react-native-swipe ...

  5. ReactNative新手学习之路03真机调试

    React Native新手入门03真机调试(iOS) 从设备访问开发服务器 在启用开发服务器的情况下,你可以快速的迭代修改应用,然后在设备上查看结果.这样做的前提是你的电脑和设备必须在同一个wifi ...

  6. ReactNative新手学习之路02第一个RN项目

    开始第一个RN项目(iOS版)我的电影列表0.1版,后面做列表版 打开上一节项目 index.ios.js,android打开index.android.js.我这里使用的是Atom编辑器,你也可以使 ...

  7. ReactNative新手学习之路06滚动更新ListView数据的小示例

    本节带领大家学习使用ListView 做一个常用的滚动更新数据示例: 知识点: initialListSize={200} 第一次加载多少数据行 onEndReached={this.onEndRea ...

  8. ReactNative新手学习之路05 使用夜神模拟器调试ReactNative

    1.首先确保adb环境添加到path环境   2.安装好夜神模拟器   3.运行模拟器   4.adb connect 127.0.0.1:62001   5.摇一摇设置IP和端口 如127.168. ...

  9. 阶段5 3.微服务项目【学成在线】_day04 页面静态化_13-页面静态化-数据模型-轮播图DataUrl接口

    要开发轮播图的DataUrl的接口 轮播图的配置的集合 xc-framework-model这个module下 CmsConfigModel的类的属性 定义接口 在api里面定义接口:CmsConfi ...

随机推荐

  1. Sqlserver 中系统表sysobjects、syscolumns以及函数object_id

    1.sysobjects 系统对象表. 保存当前数据库的对象,如约束.默认值.日志.规则.存储过程等 sysobjects 重要字段解释: sysObjects ( Name sysname, --o ...

  2. CSS实现弹出导航菜单

    查看实际效果:http://keleyi.com/a/bjac/vksd7321.htm 完整代码,保存在html文件打开也可看到效果: <!DOCTYPE html PUBLIC " ...

  3. The operation couldn’t be completed. (LaunchServicesError error 0.)

    问题描述: 当运行Xcode时,编译代码成功,但是登陆模拟器失败,显示错误:The Operation couldn't be completed.(LaunchServicesError error ...

  4. transform图形变化

    <!DOCTYPE HTML> <head> <meta charset = "utf-8"> <title>canvas</ ...

  5. INITIAL参数设置导致TRUNCATE TABLE不能降低高水位线案例

    在一个数据库使用下面SQL找出了一批需要降低高水位线的表,其中有几个表没有数据,于是我打算用TRUNCATE来降低高水位线HWM SELECT a.owner,        a.segment_na ...

  6. SQLite学习笔记(九)&&pager模块

    概述 通过上一篇文章的分析,我们知道了pager模块在整个sqlite中所处的位置.它是sqlite的核心模块,充当了多种重要角色.作为一个事务管理器,它通过并发控制和故障恢复实现事务的ACID特性, ...

  7. W3School-CSS 伪类 (Pseudo-classes) 实例

    CSS 伪类 (Pseudo-classes) 实例 CSS 实例 CSS 背景实例 CSS 文本实例 CSS 字体(font)实例 CSS 边框(border)实例 CSS 外边距 (margin) ...

  8. Nova Suspend/Rescue 操作详解 - 每天5分钟玩转 OpenStack(35)

    本节我们讨论 Suspend/Resume 和 Rescue/Unrescue 这两组操作. Suspend/Resume 有时需要长时间暂停 instance,可以通过 Suspend 操作将 in ...

  9. 计算节点宕机了怎么办?- 每天5分钟玩转 OpenStack(43)

    Rebuild 可以恢复损坏的 instance. 那如果是宿主机坏了怎么办呢? 比如硬件故障或者断电造成整台计算节点无法工作,该节点上运行的 instance 如何恢复呢? 用 Shelve 或者 ...

  10. android 获取应用的当前版本号&获取当前android系统的版本号

    (转自:http://www.cnblogs.com/qsl568/archive/2012/03/14/2395636.html) 获取当前应用的版本号: private String getVer ...