【uniapp】 判断浏览器环境
生活随笔
收集整理的這篇文章主要介紹了
【uniapp】 判断浏览器环境
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
//平臺(tái)、設(shè)備和操作系統(tǒng)
var system = {win: false,mac: false,xll: false,ipad: false,
};//檢測(cè)平臺(tái)(win系統(tǒng),mac系統(tǒng),Linux系統(tǒng),ipad)
var p = navigator.platform;
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = p == "X11" || p.indexOf("Linux") == 0;
system.ipad = navigator.userAgent.match(/iPad/i) != null ? true : false;//檢測(cè)微信
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.match(/MicroMessenger/i) == "micromessenger"if (isWeixin) {//微信瀏覽器// console.log("weixin");
} else {if (system.win || system.mac || system.xll || system.ipad ) {// console.log("pc");//pc} else {// console.log("mobile");//手機(jī)瀏覽器}
}
總結(jié)
以上是生活随笔為你收集整理的【uniapp】 判断浏览器环境的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 基于GLFW的OpenGL学习001_艾
- 下一篇: ISO7816 调试心得