微信小程序

1.iphone全面屏安全区设置

constant(safe-area-inset-bottom)
env(safe-area-inset-bottom)

可以根据具体业务做具体j计算页面上view高度或者padding等

2.自定义顶部高度

wxml:

  <view class="header nav-wrap" style='height: {{height*2 + 20}}px;{{headerStyle}}'>
    <image src="/static/images/index_header_bg.png" mode="widthFix" class="bg"></image>
    <view class='nav-title title' style='line-height: {{height*2 + 44}}px;'>
      <image class="logo" src="/static/images/index_logo.png"></image>
      你的标题
    </view>

  </view>

页面js:

data:{
height: app.globalData.height,
}

app.js

    wx.getSystemInfo({
      success: (res) => {
        this.globalData.height = res.statusBarHeight
      }
    })

  globalData: {
    height:0
  }

如在滚动页面过程中有需要处理的逻辑或者样式等,在onPageScroll里面去实现:

  onPageScroll: function (e) { // 获取滚动条当前位置
    let scrollTop = e.scrollTop
    if (scrollTop >= (this.data.height * 3 )) {//这里的 this.data.height * 3 是我根据我的业务逻辑来做的判断 ,你可以使用你应用需要的值
      let h = this.data.height*2+44
      处理你的逻辑...
    } else {
    处理你的逻辑...
    }
  },    
技术最菜,头发最少
原文地址:https://www.cnblogs.com/gushengyan/p/14913069.html