小程式iPhone X以上適配安全區域
阿新 • • 發佈:2020-12-19
技術標籤:小程式
看來程式碼不能光靠技術牛逼,腦回路也要牛逼
本頁js
data:{
isIPhoneX: false,
},
onLoad: function (options) {
const isIPhoneX = () => {
let screenHeight = wx.getSystemInfoSync().screenHeight
let bottom = wx.getSystemInfoSync().safeArea.bottom
return screenHeight !== bottom
}
that. setData({
isIPhoneX:isIPhoneX()
})
}
本頁wxml
<!-- 購物車底部按鈕部分-->
<view class="product-detail-btns bgf tc bort1 {{isIPhoneX?'fix-iphonex-button':''}}" style="background:#fff">
</view>
<!-- 底部彈出規格選擇 -->
<view class="animation-bottom {{isIPhoneX?'ip':''}} {{showView?'up':'down'}} product-det-size-areas" >
</view>
本頁wxss
.fix-iphonex-button{
bottom: 68rpx !important;
}
.fix-iphonex-button::after {
content: ' ';
position: fixed;
bottom: 0!important;
height: 68rpx!important;
width: 100%;
background: #fff;
}
// {{isIPhoneX?'ip':''}} 蘋果下的ip裡邊的up
page .animation-bottom.ip.up{
bottom: 68rpx !important;
}