看到官方组件里的是判断是否为安卓:
lifetimes: {
attached() {
const rect = wx.getMenuButtonBoundingClientRect()
const platform = (wx.getDeviceInfo() || wx.getSystemInfoSync()).platform
const isAndroid = platform === 'android'
const isDevtools = platform === 'devtools'
const { windowWidth, safeArea: { top = 0, bottom = 0 } = {} } = wx.getWindowInfo() || wx.getSystemInfoSync()
this.setData({
ios: !isAndroid,
innerPaddingRight: `padding-right: ${windowWidth - rect.left}px`,
leftWidth: `width: ${windowWidth - rect.left}px`,
safeAreaTop: isDevtools || isAndroid ? `height: calc(var(--height) + ${top}px); padding-top: ${top}px` : ``
})
},
},就按官方的写了,之前查的怕以后找不到,暂时先留个底。
const windowInfo = wx.getWindowInfo();
const deviceInfo = wx.getDeviceInfo();
const isIOS = deviceInfo.platform === 'ios' || deviceInfo.system.toLowerCase().includes('ios');

