app.js里面判断是否为iPhone X
// 获取设备信息let _this = this;wx.getSystemInfo({ success(res) { let deviceModel = 'iPhone X'; if (res.model.indexOf(deviceModel) > -1) { console.log(res.model); _this.globalData.isIpx = true; } },});
在wxml文件中class里面写上三目运算符,在wxss里面给iPhone X写上独立的样式
立即购买 立即购买
在其他页面如下代码获取isIphoneX的值
isIphoneX: app.globalData.isIphoneX,//是否是IphoneX
wxss部分:
.fix-iphonex-button { bottom: 68rpx !important;}.fix-iphonex-button::after { content: ''; position: fixed; bottom: 0 !important; height: 68rpx !important; width: 100%; background: #fff;}