js判断项目是pc还是移动端打开

function IsPC() {
    const userAgentInfo = navigator.userAgent;
    const Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
    let flag = true;
    for (let v = 0; v < Agents.length; v++) {
      if (userAgentInfo.indexOf(Agents[v]) > 0) {
        flag = false;
        break;
      }
    }
    console.log(flag);
    return flag;
}

 

posted @ 2020-08-03 10:30  叶子0321~  阅读(144)  评论(0编辑  收藏  举报