微信小程序识别苹果齐刘海机型

微信小程序识别苹果齐刘海机型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
* 判断是否为苹果齐刘海机型
*
* @return {bool}
*/
function has_iphone_bangs() {
const system = wx.getSystemInfoSync();

// 非苹果品牌
if(system.brand !== 'iPhone') {
return false;
}

return /^(iPhone (X|1[\d])|unknown)/.test(system.model);
}

其他

1
2
3
4
5
6
7
8
/* 安全区域处理 */

padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);

padding-bottom: 10rpx;
padding-bottom: calc(10rpx + constant(safe-area-inset-bottom));
padding-bottom: calc(10rpx + env(safe-area-inset-bottom));

参考

wx.getSystemInfoSync获取model为unknow

往上