初学:react-native 轮播图
参考资料:http://reactscript.com/react-native-card-carousel-component/
import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    Image,
    View
} from 'react-native';
import CarouselCard from '../carouselCard/Card';
import Carousel, {Pagination} from 'react-native-snap-carousel';
// ES6生成组件 (推荐)
export default class MyCarouselCard extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            itemArr: [
                require('../images/sowingone.png'),
                require('../images/sowingtwo.png'),
                require('../images/sowingthree.png')
            ]
}
    }
    _renderItem({item, index}) {
        return <MySlideComponent data={item}/>
    }
    get pagination() {
        const {itemArr, activeSlide} = this.state;
        return (
            <Pagination
                dotsLength={this.state.itemArr.length}
                activeDotIndex={activeSlide}
                containerStyle={{backgroundColor: 'rgba(0, 0, 0, 0.75)'}}
                dotStyle={{
                    width: 30,
                    height: 30,
                    borderRadius: 10,
                    marginHorizontal: 8,
                    backgroundColor: 'red'
                }}
                inactiveDotStyle={{
                    width: 30,
                    height: 30,
                    borderRadius: 10,
                    marginHorizontal: 8,
                    backgroundColor: '#000'
                }}
                inactiveDotOpacity={0.4}
                inactiveDotScale={0.6}
            />
        );
    }
    render() {
        return (
            <View style={styles.cont}>
                <View style={styles.container}>
                    <CarouselCard
                        width={596}
                        height={403}
                        backgroundColor='red'
                        autoplay
                        interval={4000}
                        data={this.state.itemArr}
                        onPress={item => {
                        }}
                        contentRender={item => <Image source={item} style={{width: 596, height: 403}}/> }
                    />
                </View>
                <View style={styles.cont1}>
                    <Carousel
                        itemWidth={500}
                        itemHeight={300}
                        windowSize={10}
                        data={this.state.itemArr}
                        renderItem={this._renderItem}
                        onSnapToItem={(item) => this.setState({activeSlide: item})}
                    />
                    {this.pagination}
                </View>
            </View>
)
    }
}
const styles = StyleSheet.create({
    container: {
        flex:4,
        width:980,
        height:450,
        backgroundColor: 'blue'
    },
    cont: {
        flex:1,
        flexDirection:"column",
        width: 1000,
        height:550,
        borderWidth: 2
    },
    cont1: {
        flex:1
    },
    item: {
        width: 700,
        height: 100
    }
});
初学:react-native 轮播图的更多相关文章
- React Native学习(六)—— 轮播图
		本文基于React Native 0.52 Demo上传到Git了,有需要可以看看,写了新内容会上传的.Git地址 https://github.com/gingerJY/React-Native-D ... 
- React Native 如何做轮播图 react-native-swiper
		//:仿饿了么github:https://github.com/stoneWeb/elm-react-native 欢迎各位同学加入: React-Native群:397885169 大前端群:54 ... 
- React Native 之轮播图swiper组件
		注释:swiper组件是第三方组件 所以在使用之前应该先在命令行安装,然后将第三方的模块引入(第三方模块地址:https://github.com/leecade/react-native-swipe ... 
- React Native布局实践:开发京东client首页(三)——轮播图的实现
		上篇文章中,我们一起构建了京东client的TabBar.在本文中.将继续向大家介绍京东client首页轮播图及其下发功能button的开发方法,如今就让我们開始吧! 1.相关控件调研 眼下在Gith ... 
- React视角下的轮播图
		天猫购物网站最显眼的就是轮播图了.我在学习一样新js库,一个新框架或新的编程思想的时候,总是感叹"入门必做选项卡,进阶须撸轮播图."作为一个React组件,它是状态操控行为的典型, ... 
- React中使用CSSTransitionGroup插件实现轮播图
		动画效果,是一个页面上必不可少的功能,学习一个新的东西,当然就要学习,如何用新的东西,用它的方法去实现以前的东西啦.今天呢,我就在这里介绍一个试用react-addons-css-transition ... 
- React 轮播图实现
		接到项目, 用react和material-ui实现轮播图. 搜索了一些方法参考, 不论语言/框架的使用,大体上分为两种思路 超宽列表实现法 在原生JS或者JQuery中,轮播图的实现一般是这样子的 ... 
- reactjs-swiper  react轮播图组件基于swiper
		react轮播图组件基于swiper demo地址:http://reactjs-ui.github.io/reactjs-swiper/simple.html 1. 下载安装 npm install ... 
- react轮播图----react-slick
		1.安装 npm install react-slick; //安装样式 npm install slick carousel; 再在App.css中引入 @import "~slick-c ... 
随机推荐
- 7 . 动态sql-choose
			choose-when-otherwise 只能满足一个when 中的条件,互斥的条件,不能同时存在 mapper.xml <select id="selectstateByTitle ... 
- react 中文文档案例五 (循环列表)
			function NumberList(props) { const numbers = props.numbers; const listItems = numbers.map((number) = ... 
- CRF++使用步骤
			1.将CRF++文件的压缩包解压后添加到java的工程目录下 2.使用前必须生成train.data和test.data 文件并放到crf_learn.exe的同级目录下 3.cmd进入目标位置,其中 ... 
- javascript中的一元操作符
			题目如下: var s1 = "01"; var s2 = "1.1"; var s3 = "z"; var b = false; var ... 
- linux学习四x系统指令
			一.任务调度 任务调度:系统在某个时间执行特定的命令或者程序 如: 1.对于一些需要周期性执行的一些系统指令 2.定期的病毒扫描 3.定期数据库备份等 命令:crontab 设置任务调度文件: / ... 
- Nginx静态服务,域名解析
			安装这里就不写了在LNMP里有具体的安装 1.1 常用来提供静态Web服务的软件有如下三种:  Apache:这是中小型Web服务的主流,Web服务器中的老大哥.  Nginx:大型网 ... 
- 使用spyder编译器单步调试python
			1.将需要进行单步调试的函数在脚本中进行调用(十分重要的一步).由于python是解释型语言,在进行单步调试的时候需要告诉系统你使用了这个函数,单步调试才会进入你所需要调式的函数.如下图所示,我们定义 ... 
- java——变量
			1.静态变量: 随着类的加载而生成并初始化 随着类的消失而消失 2.成员变量: 随对象的加载而生成并初始化 随对象被回收而消失 3.局部变量: 作用范围由{}决定 随方法调用而创建 随方法的执行完毕而 ... 
- Vue.js-----轻量高效的MVVM框架(八、使用组件)
			什么是组件? 组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素,Vue.js 的编译器为它添加特殊功能.在有 ... 
- strcpy/strlen/strcat/strcmp的实现
			一.字符串拷贝strcpy 函数strcpy的原型是char* strcpy(char* des , const char* src),des 和 src 所指内存区域不可以重叠且 des 必须有足够 ... 
