- app.js 通过 wx.getSystemInfoSync 获取 statusBarHeight 存入 globalData
- 所有12个自定义导航页面的 JS 读取 statusBarHeight
- WXML 通过 style="padding-top: {{statusBarHeight + 24}}px" 动态适配
- 普通手机和灵动岛手机都能正确显示
19 行
353 B
JavaScript
19 行
353 B
JavaScript
Page({
|
|
data: {
|
|
statusBarHeight: 44
|
|
},
|
|
|
|
onLoad: function () {
|
|
var app = getApp()
|
|
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
|
},
|
|
|
|
onViewPlans: function () {
|
|
wx.navigateTo({ url: '/pages/subscribe-plans/subscribe-plans' })
|
|
},
|
|
|
|
onBack: function () {
|
|
wx.switchTab({ url: '/pages/index/index' })
|
|
}
|
|
})
|