Showing
2 changed files
with
34 additions
and
0 deletions
| @@ -57,6 +57,23 @@ Page({ | @@ -57,6 +57,23 @@ Page({ | ||
| 57 | * 生命周期函数--监听页面显示 | 57 | * 生命周期函数--监听页面显示 |
| 58 | */ | 58 | */ |
| 59 | onShow: function () { | 59 | onShow: function () { |
| 60 | + //导航栏自适应 | ||
| 61 | + let systemInfo = wx.getSystemInfoSync(); | ||
| 62 | + let reg = /ios/i; | ||
| 63 | + let pt = 20;//导航状态栏上内边距 | ||
| 64 | + let h = 44;//导航状态栏高度 | ||
| 65 | + if (reg.test(systemInfo.system)) { | ||
| 66 | + pt = systemInfo.statusBarHeight; | ||
| 67 | + h = 44; | ||
| 68 | + } else { | ||
| 69 | + pt = systemInfo.statusBarHeight; | ||
| 70 | + h = 48; | ||
| 71 | + } | ||
| 72 | + this.setData({ | ||
| 73 | + statusBarHeight: pt, | ||
| 74 | + titleBarHeight: h, | ||
| 75 | + height: systemInfo.windowHeight | ||
| 76 | + }) | ||
| 60 | this.getDetail(); | 77 | this.getDetail(); |
| 61 | }, | 78 | }, |
| 62 | 79 |
| @@ -59,6 +59,23 @@ Page({ | @@ -59,6 +59,23 @@ Page({ | ||
| 59 | * 生命周期函数--监听页面显示 | 59 | * 生命周期函数--监听页面显示 |
| 60 | */ | 60 | */ |
| 61 | onShow: function () { | 61 | onShow: function () { |
| 62 | + //导航栏自适应 | ||
| 63 | + let systemInfo = wx.getSystemInfoSync(); | ||
| 64 | + let reg = /ios/i; | ||
| 65 | + let pt = 20;//导航状态栏上内边距 | ||
| 66 | + let h = 44;//导航状态栏高度 | ||
| 67 | + if (reg.test(systemInfo.system)) { | ||
| 68 | + pt = systemInfo.statusBarHeight; | ||
| 69 | + h = 44; | ||
| 70 | + } else { | ||
| 71 | + pt = systemInfo.statusBarHeight; | ||
| 72 | + h = 48; | ||
| 73 | + } | ||
| 74 | + this.setData({ | ||
| 75 | + statusBarHeight: pt, | ||
| 76 | + titleBarHeight: h, | ||
| 77 | + height: systemInfo.windowHeight | ||
| 78 | + }) | ||
| 62 | this.getDetail(); | 79 | this.getDetail(); |
| 63 | }, | 80 | }, |
| 64 | 81 |
-
Please register or login to post a comment