react swiper bug 偶尔不展示

2020-11-25  本文已影响0人  曾经也是个少年

这个是数组为0是,初始化的swiper 对后续的swiper有影响了,加个 长度不等于零的判断

{
            props.model.length>0 ? <Swiper
                className='test-h'
                indicatorColor='#5F7C99'
                indicatorActiveColor='#297AF8'
                vertical={false}
                circular
                style={{ height: `${props.height}px` }}
                indicatorDots
                autoplay>
                {
                    props.model.map((item, index) => {
                        return <SwiperItem key={index}>
                            <Image src={item} className="img"></Image>
                        </SwiperItem>
                    })
                }

            </Swiper> : null
        }
上一篇 下一篇

猜你喜欢

热点阅读