最近在項目遇到swiper高度不能自適應,導致swiper-item 里面的內容過多時只能顯示一部分,最終解決方案:
<swiper current="{{currentTab}}" style="height: {{clientHeight?clientHeight+'px':'auto'}}"> <swiper-item> <scroll-view scroll-y="{{true}}" style="height: {{clientHeight?clientHeight+'px':'auto'}}" bindscrolltolower="scrollbot"> 內容放在這 </scroll-view> </swiper-item> </swiper>
swiper-item {
overflow: scroll;
}
最后在后台動態獲得屏幕可視區域高度clientHeight即可
onLoad: function () { var that = this wx.getSystemInfo({ success: function (res) { that.setData({ clientHeight: res.windowHeight-177 }); } }) }