微信小程序获取状态栏高度

  data: {
    statusbar: 0
  },
 页面获取状态栏高度
  onLoad: function (e) {
    const res = wx.getSystemInfoSync()
    var statusbarH = res.statusBarHeight
    this.setData({
        statusbar :statusbarH
    })
},
 组件获取状态栏高度
  attached() {
    const res = wx.getSystemInfoSync()
    var statusbarH = res.statusBarHeight
    this.setData({
      statusbar: statusbarH
    })
  },
posted @ 2020-09-15 14:36  web格调  阅读(5111)  评论(0编辑  收藏  举报