swiper中的内容高度不能自适应100%

发布于 6 年前作者 longyong7600 次浏览最后编辑 6 年前来自 ask

这个swiper组件,我用它来弄tab栏目滑动,但是高度不能自适用呢

高度不能够自适应100%

4 回复
ylu
ylu1 楼6 年前

<swiper wx:for=‘{{array}}’ style=‘height:{{ heights[index] || 50 }}px’ >

    <swiper-item>

        <view class=‘getThisHeight’>

            …这里放自适应内容

        </view>

    </swiper-item>

</swiper>

justifyHeight: function () {

    let that = this

    let hs = []

    wx.createSelectorQuery().selectAll(‘.getThisHeight).boundingClientRect(function (rects) {

        rects.forEach((v, i) => {

            hs[i] = v.height

        })

        that.setData({

            heights: hs,

        })

    }).exec()

},

xiayu
xiayu2 楼6 年前

有解决吗?我也遇到了这个问题

shaoyan
shaoyan3 楼6 年前

可以尝试在swiper标签下面嵌套一个 scroll-view 标签尝试下

xcui
xcui4 楼4 年前

我也遇到了同样的问题,兄弟解决了吗?