react-native-swiper 使用遇到的坑

首先是把react-native-swiper 引入到项目中,先cd到项目跟目录下,再

$ npm i react-native-swiper --save

完成后在项目中要使用的地方import 进来
import Swiper from 'react-native-swiper';

在return()中使用就OK,如:
return (
            <Swiper
                style={styles.wrapper}
                showsButtons={true}    //显示左右点击的按钮
                loop = {true}
                autoplay = {true}
                height={200}    //没有效果
            >

                <View style={styles.slide1}>

                    <Image style={{width: 300, height: 190}}
                           resizeMethod='stretch'
                           source={{uri: 'https://www.baidu.com/img/bd_logo1.png'}}
                    />

                    <Text style={styles.text}>滑动试图第一页</Text>
                </View>
                <View style={styles.slide1}>
                    <Text style={styles.text}>滑动试图第二页</Text>
                </View>
                <View style={styles.slide1}>
                    <Text style={styles.text}>滑动试图第三页</Text>
                </View>
            </Swiper>

        )
但是这里就遇到个坑,swiper打开一直是个全屏的,在属性里怎么修改也无效。
后来我把react-native-swiper封装成一个组件,在引用时在外层的View定义height,发现是有效果的。


学习中,仅当自己学习笔记。不准确的地方不定期更新!!!

转载于:https://www.cnblogs.com/Stone-Yuan/p/7649178.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值