wx.getSystemInfo({ success: function (res) { that.globalData.winWidth = res.windowWidth; that.globalData.winHeight = res.windowHeight; } })
以上,app.js中 先获取整体高度 赋值给全局变量
<swiper class='swiper' current="{{currentTab}}" duration="300" bindchange="bindChange" style="height:{{winHeight}}px">
以上.wxml代码 style height 赋值 使用方法
//定义高度 Page({ data: { winHeight: 0 }, }) onLoad: function (options) { this.setData({ winHeight: app.globalData.winHeight - wx.getSystemInfoSync().screenWidth / 750 * (155) }) }
以上 js 是其他控件预留 155rpx情况下
swiper 控件的高度