• 判断ios还是android的公共方法


    1:在common文件下index.js中写入方法并导出

    export var isMobile = {
      Android: function () {
        return !!navigator.userAgent.match(/Android/i);
      },
      iOS: function () {
        return !!navigator.userAgent.match(/iPhone|iPad|iPod/i);
      }
    }

    2:在需要使用的文件下引入

    import { isMobile } from '@/common'

    3:使用isMobile下的方法

    if (isMobile.iOS()) {
     alert('i am ios')
    }
    if (isMobile.Android()) {
      alert('i am Android')
    }
  • 相关阅读:
    05
    04
    03
    02
    01
    drf 频率类
    drf 视图家族
    drf 之 群改,单改接口
    drf 序列化
    drf 之模块
  • 原文地址:https://www.cnblogs.com/liangpi/p/11836285.html
Copyright © 2020-2023  润新知