小程序兼容蘋果11,12,X底部小黑條處理


 

 

 小程序在iphoneX下,底部固定定位的塊會被蘋果手機的小黑條擋住,其實影響也不大,但是設計過不去,改

 

 

 公用方法

export const isDiffDeviceModel = async () => {
  let sysInfo = await wx.getSystemInfoSync();
  console.log(sysInfo);
  let deviceModel = sysInfo.model;
  let flag = false;
  if (deviceModel.indexOf("iPhone X") > -1 || deviceModel.indexOf("iPhone 11") > -1 || deviceModel.indexOf("iPhone 12") > -1) {
    flag = true;
  }
  return flag;
}

然后在app.ts里面定義一個變量diffDeviceModel

在首頁調用一下方法即可,然后存在全局變量里面

this.globalData.diffDeviceModel=await  isDiffDeviceModel();

使用的時候只需要通過變量的diffDeviceModel true和false設置不同的樣式即可

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM