动态获取设备的高度,然后再wxss中设置高度
使用 getSystemInfoSync() 来获取设备信息...... https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfo.html
1 <scroll-view class="scroll-view" scroll-y="true" style="height:{{winHeight}}px"> 2 3 </scroll-view>
1 .scroll-view{ 2 width: 100%; 3 /* height: 500px; 写到wxml 的 style中了 */ 4 background-color: cyan; 5 }
1 Page({ 2 3 /** 4 * 页面的初始数据 5 */ 6 data: { 7 8 }, 9 10 /** 11 * 生命周期函数--监听页面加载 12 */ 13 onLoad: function (options) { 14 var systemInfo = wx.getSystemInfoSync(); 15 console.log(systemInfo); 16 var winHeight = systemInfo.windowHeight; 17 var winWidth = systemInfo.windowWidth; 18 this.setData({ 19 winWidth:winWidth, 20 winHeight:winHeight 21 }); 22 23 }, 24 })