我是靠谱客的博主 要减肥棒棒糖,这篇文章主要介绍判断ios,安卓,pad,还是pc,现在分享给大家,希望可以做个参考。

  // iOS 代码
  // window.webkit.messageHandlers.immediateUseCoupon.postMessage({})
  // 安卓 代码
  // window.webkit.immediateUseCoupon()
  // 原生智慧加油的使用 需要做用户车型限制的。 跳转之前要判断一下。
  export const getOS = () => {
    var ua = navigator.userAgent;
    if (ua.match(/iPhone|iPod/i) != null) {
      //iphone代码
      return 'iOS';
    } else if (ua.match(/Android/i) != null) {
      //android代码
      return 'Android';
    } else if (ua.match(/iPad/i) != null) {
      //ipad代码
      return 'iPad';
    }
    return 'pc';
  }

使用:

const currentOS = getOS();
try {
   if (currentOS == 'iOS' || currentOS == 'iPad') {
     // iOS 代码
     // window.webkit.messageHandlers.immediateUseCoupon.postMessage({})
     window.webkit.messageHandlers.immediateUseCoupon.postMessage('');
   } else if (currentOS == 'Android') {
     // 安卓 代码
     // window.webkit.immediateUseCoupon()
     window.webkit.immediateUseCoupon();
   }
   this.talkingdata('去加油点击', {'userId': this.blindBoxInfo.userId});
 } catch (e) {
   MessageBox.alert(
     '当前版本不支持智慧加油,赶紧去应用市场下载最新版本的日产智联吧~',
     '版本更新提醒'
   ).then(action => {
     this.closeWebPage();
   });
 }

最后

以上就是要减肥棒棒糖最近收集整理的关于判断ios,安卓,pad,还是pc的全部内容,更多相关判断ios内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部