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,發現是有效果的。


學習中,僅當自己學習筆記。不准確的地方不定期更新!!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM