美文网首页
判断JS运行环境

判断JS运行环境

作者: Mr老朝 | 来源:发表于2019-02-13 14:50 被阅读0次
const inBrowser = typeof window !== 'undefined'

const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform
const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase()

const UA = inBrowser && window.navigator.userAgent.toLowerCase()

const isIE = UA && /msie|trident/.test(UA)
const isIE9 = UA && UA.indexOf('msie 9.0') > 0
const isEdge = UA && UA.indexOf('edge/') > 0
const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android')
const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
const isPhantomJS = UA && /phantomjs/.test(UA)
const isFF = UA && UA.match(/firefox\/(\d+)/)

相关文章

  • 判断JS运行环境

  • nuxt.js打包删除console.log

    1 2在config.js添加外面判断生产环境还是开发环境 build里 完美运行

  • 运行环境判断

    Unity 运行环境宏判别,用于限制一些函数在特定地方才执行 https://qiita.com/Ubermens...

  • 2019-06-15

    Node.js、Vue.js 运行环境搭建记录 参考链接:Vue.js 运行环境搭建详解(基于windows的手把...

  • js判断运行平台

  • vue 环境搭配

    vue.js的运行环境配置主要分为3步: 1.安装Node.js(JavaScript运行环境) 2.安装Vue....

  • 03-Node.js

    Node.js是基于Chrome V8引擎的JS的后端运行环境,前端运行环境是浏览器。Node.js不能调用Web...

  • php

    介绍: html css js运行环境为浏览器,浏览器在window上运行. 运行环境:wamp phpstudy...

  • 搭建Node.js环境

    搭建Node.js环境 安装 Node.js 环境 Node.js 是运行在服务端的 JavaScript, 是基...

  • nodejs的安装

    环境搭建 Node.js: javascript运行环境(runtime),不同系统直接运行各种编程语言 npm:...

网友评论

      本文标题:判断JS运行环境

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