【uniapp】 判断浏览器环境
生活随笔
收集整理的這篇文章主要介紹了
【uniapp】 判断浏览器环境
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//平臺、設備和操作系統
var system = {win: false,mac: false,xll: false,ipad: false,
};//檢測平臺(win系統,mac系統,Linux系統,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;//檢測微信
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");//手機瀏覽器}
}
總結
以上是生活随笔為你收集整理的【uniapp】 判断浏览器环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于GLFW的OpenGL学习001_艾
- 下一篇: 小饶学编程之JAVA SE第二部分——W