参考资料: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 轮播图的更多相关文章

  1. React Native学习(六)—— 轮播图

    本文基于React Native 0.52 Demo上传到Git了,有需要可以看看,写了新内容会上传的.Git地址 https://github.com/gingerJY/React-Native-D ...

  2. React Native 如何做轮播图 react-native-swiper

    //:仿饿了么github:https://github.com/stoneWeb/elm-react-native 欢迎各位同学加入: React-Native群:397885169 大前端群:54 ...

  3. React Native 之轮播图swiper组件

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

  4. React Native布局实践:开发京东client首页(三)——轮播图的实现

    上篇文章中,我们一起构建了京东client的TabBar.在本文中.将继续向大家介绍京东client首页轮播图及其下发功能button的开发方法,如今就让我们開始吧! 1.相关控件调研 眼下在Gith ...

  5. React视角下的轮播图

    天猫购物网站最显眼的就是轮播图了.我在学习一样新js库,一个新框架或新的编程思想的时候,总是感叹"入门必做选项卡,进阶须撸轮播图."作为一个React组件,它是状态操控行为的典型, ...

  6. React中使用CSSTransitionGroup插件实现轮播图

    动画效果,是一个页面上必不可少的功能,学习一个新的东西,当然就要学习,如何用新的东西,用它的方法去实现以前的东西啦.今天呢,我就在这里介绍一个试用react-addons-css-transition ...

  7. React 轮播图实现

    接到项目, 用react和material-ui实现轮播图. 搜索了一些方法参考, 不论语言/框架的使用,大体上分为两种思路 超宽列表实现法 在原生JS或者JQuery中,轮播图的实现一般是这样子的 ...

  8. reactjs-swiper react轮播图组件基于swiper

    react轮播图组件基于swiper demo地址:http://reactjs-ui.github.io/reactjs-swiper/simple.html 1. 下载安装 npm install ...

  9. react轮播图----react-slick

    1.安装 npm install react-slick; //安装样式 npm install slick carousel; 再在App.css中引入 @import "~slick-c ...

随机推荐

  1. 用勤哲excel服务器开发旅行社管理软件

    做这个旅行社管理软件之前,旅行社给我的印象就是“拉客”与“接客”,业务模式应该比较简单.但做起这样一个旅行社管理软件,才发现麻雀虽小.五脏俱全,一个旅行社的运作,牵扯到的方方面面远远超出自己之前的理解 ...

  2. vue.js路由嵌套传参

    通过配置路由时候按照: path:/user/:username/age/:age 这种就可以把参数传递 接受: $routes.params 接受到的是一个json格式的数据,

  3. springboot整合dubbo注解方式

    工程结构: 主pom <?xml version="1.0" encoding="UTF-8"?> <project xmlns=" ...

  4. C#空接合操作符——??

    操作符: ?? 用法:C = A ?? B; 解释:if(A != null){ C=A;} else{C=B}     类似三元运算符 :? 例子: Int32? num1=null; Int32? ...

  5. Oulipo (KMP出现次数)

    The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...

  6. Educational Codeforces Round 11 B

    Description Consider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of th ...

  7. day_10 函数名,闭包,迭代器

    1. 函数名的使用 1.函数名是一个变量,函数名储存的是函数的内存地址 2.函数名可以赋值给其他变量 3.函数名可以当容器类对象的元素 4.函数名可以当其他函数的参数 5.函数名可以做函数的返回值 2 ...

  8. day_04 列表

    1. 列表list 能装对象的对象,有序的(按照我们存放的顺序) 以[]表示,里面可以存放大量各种元素,各个元组用逗号隔开 列表也具有索引和切片 2. 列表的增改删查 1. 增 1.append() ...

  9. 12.标准标签库(JSTL)

    1.JSTL标签库安装 JSTL的概念: JSP标准标签库(JSP Standard Tag Library)是一个实现 Web 应用程序中常见的通用功能的定制标记库集功能包括迭代和条件判断.数据管理 ...

  10. 使用wget下载oracle jdk1.8

    wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com% ...