首页 > 其他 > 详细

react native 中使用swiper

时间:2018-08-10 17:39:07      阅读:172      评论:0      收藏:0      [点我收藏+]

1.下载依赖

cnpm install react-native-swiper --save 

2.在组件中使用

import React, { Component } from ‘react‘;
import { StyleSheet, View,Dimensions,Image} from ‘react-native‘;
import Swiper from ‘react-native-swiper‘;
export default class SideItem extends Component {
    render(){
        return(
            <View style={styles.container}>
                <Swiper
                    style={styles.swiper}
                    height={220}
                    horizontal={true}
                    autoplay={true} 
                    paginationStyle={{bottom: 20}}
                    showsButtons={false}>
                    <Image source={require(‘../assets/images/1.png‘)} style={styles.img}/>
                    <Image source={require(‘../assets/images/2.png‘)} style={styles.img}/>
                    <Image source={require(‘../assets/images/3.png‘)} style={styles.img}/>
                </Swiper>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1
    },
    swiper: {},
    img: {
        width: Dimensions.width,
        height: 200,
    }
});

3.运行run-Android

技术分享图片

 

react native 中使用swiper

原文:https://www.cnblogs.com/ldlx-mars/p/9456438.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!