js判断移动端还是pc端

function isMobile() {
    let userAgentInfo = navigator.userAgent;
    let Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
    let getArr = Agents.filter(i => userAgentInfo.includes(i));
    return getArr.length ? true : false;
  }

判断是否是pc端

  • true: 移动端
  • false: pc端
posted @ 2022-08-17 20:46  土小狗  阅读(1622)  评论(0编辑  收藏  举报