微信小程序-获取屏幕可显示尺寸-全布局需要的

来源:互联网 发布:剑三菊花插件dbm数据 编辑:程序博客网 时间:2024/05/17 09:02

获取当前用户屏幕可显示尺寸

 在wxss中可以在

page{

overflow:hidden;

}

防止页面1/2px的滚动

onLoad: function (options) {

    var that = this
    // 获取系统信息
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        // 可使用窗口宽度、高度
        console.log('height=' + res.windowHeight);
        console.log('width=' + res.windowWidth);
        // 计算主体部分高度,单位为px
        that.setData({
          second_height: res.windowHeight
        })
      }
    })
  },
原创粉丝点击