美文网首页小程序开发
小程序:适配iPhone 11及以上机型兼容性

小程序:适配iPhone 11及以上机型兼容性

作者: 东方晓 | 来源:发表于2021-12-28 11:42 被阅读0次

    2021-12-28 周二

    图为iPhone 12 机型 需要处理刘海和底部黑边的问题

    在小程序中判断机型、要在App.js文件中进行。

    App({
      onLaunch() {
        // 获取设备信息
        wx.getSystemInfo({
          success: res => {
            let model = res.model;
            if (/iphone\sx/i.test(model) || (/iphone/i.test(model) && /unknown/.test(model)) || /iphone\s11/i.test(model) || /iphone\s12/i.test(model) || /iphone\s13/i.test(model)) {
              console.log('res.model', res.model)
              wx.setStorageSync('isPhoneModel', true)
            } else {
              wx.setStorageSync('isPhoneModel', false)
            }
          },
          fail: err => {},
          complete: res => {}
        })
      },
    }
    

    相关文章

      网友评论

        本文标题:小程序:适配iPhone 11及以上机型兼容性

        本文链接:https://www.haomeiwen.com/subject/yhlpqrtx.html