1.在app.js内判断
App({isIPhoneX: false, // 当前设备是否为 iPhone XkBottomSafeHeight: 0, // X 34 ,其余 0 // 判断设备是否为 iPhone XcheckIsIPhoneX: function () {var that = thiswx.getSystemInfo({success: function (res) {var safeBottom = res.screenHeight - res.safeArea.bottomthat.kBottomSafeHeight = safeBottom//根据安全高度判断if (safeBottom === 34) {that.isIPhoneX = true}}})},onLaunch() {this.checkIsIPhoneX()}})
在其他页面直接使用app.kBottomSafeHeight引用