react-native 轮播图
来源:互联网 发布:微商裂变软件 编辑:程序博客网 时间:2024/06/04 05:19
//插件安装
$ npm install react-native-swiper--save
$ npm i react-timer-mixin--save
我项目的源码:
注:这个是我的轮播图板块,this.props.item为我调用该模板传递过来的数据
/**
* Created by YangZe on 2017/5/17.
*/
import React, {Component} from 'react';
import {
StyleSheet,
View,
Text,
Image,
TouchableHighlight
} from 'react-native';
import Swiper from 'react-native-swiper' //引入第三方插件
export default class slideshow extends Component {
render() {
return (
<Swiper height={200}
paginationStyle={{bottom: 10, left: 270}}
autoplay={true}
autoplayTimeout={5}
dot={
<View style={{
width: 4,
height: 4,
backgroundColor: 'white',
borderRadius: 4,
marginLeft: 3,
marginRight: 3
}}>
</View>
}
activeDot={
<View style={{
width: 4,
height: 4,
backgroundColor: 'red',
borderRadius: 4,
marginLeft: 3,
marginRight: 3
}}>
</View>
}
>
{/*{this.renderImg()}*/}
{this.props.item.map((x) => {
return (
<View key={x.home_image} style={{flex: 1}}>
<TouchableHighlight style={{flex: 1}}
onPress={() => {
this._onSlideShowClick(x)
}
}> //图片点击事件
<Image
style={{flex: 1}}
source={{uri: x.home_image}}
>
<View style={{
backgroundColor: 'rgba(0,0,0,0.4)',
position: 'absolute',
bottom: 0,
flex: 1,
flexDirection: 'row'
}}>
<Text style={{padding: 5, color: '#fff', flex: 1}} numberOfLines={1}>
{x.title}
</Text>
</View>
</Image>
</TouchableHighlight>
</View>
)
})
}
</Swiper>
);
}
_onSlideShowClick(x) {
console.log(x.title)
}
//博主的方法
// renderImg(){
// var imageViews=[];
// for(var i=0;i<this.props.item.length;i++){
// imageViews.push(
//
// <Image
// key={i}
// style={{flex:1}}
// source={{uri:this.images[i]}}
// >
// <View style={{backgroundColor:'rgba(0,0,0,0.4)',position:'absolute',bottom:0,flex:1,flexDirection:'row'}}>
// <Text style={{padding:5,color:'#fff',flex:1}} numberOfLines={1}>
// {this.props.item[i].title}
// </Text>
// </View>
// </Image>
// );
// }
// return imageViews;
// }
}
阅读全文
0 0
- react-native 轮播图
- react-native实现轮播图
- React-Native学习--轮播图第三方组件-react-native-swiper
- React-Native学习--轮播图第三方组件-react-native-swiper
- react-native 轮播图 ——react-native-swiper使用
- react native
- React Native
- React Native
- React- Native
- react-native
- React Native
- React Native
- react native
- React Native
- react-native
- React Native
- react native
- React Native
- Controller中private方法注入的Service为null
- CommandBehavior.CloseConnection
- DOS常用命令(持续更新中)
- Windows系统
- [云框架]FaaS & Serverless架构 / [Cloud Frameworks]Function as a Service & Serverless Architectures
- react-native 轮播图
- Centos7上安装Jenkins
- 【小制作】WIFI智能窗帘的制作
- 69. Sqrt(x)
- Python官网下载python3.5.0的执行程序无法运行
- 事务和异常易出现的错误
- http协议详解
- 在win10 上安装Oracle出现“INS-13001环境不满足最低要求”解决办法
- visualizing and understanding convolution network论文