1
0

navigation-bar.js 681 B

1234567891011121314151617181920212223
  1. Component({
  2. properties: {
  3. background: {
  4. type: String,
  5. value: ''
  6. }
  7. },
  8. lifetimes: {
  9. attached() {
  10. const deviceInfo = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync()
  11. const windowInfo = wx.getWindowInfo ? wx.getWindowInfo() : wx.getSystemInfoSync()
  12. const platform = deviceInfo.platform
  13. const isAndroid = platform === 'android'
  14. const isDevtools = platform === 'devtools'
  15. const { safeArea: { top = 0 } = {} } = windowInfo
  16. this.setData({
  17. ios: !isAndroid,
  18. safeAreaTop: isDevtools || isAndroid ? `height: calc(var(--height) + ${top}px); padding-top: ${top}px` : ``
  19. })
  20. }
  21. }
  22. })