< 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()
},