common.js 406 Bytes
// 判断浏览器是移动端还是pc端
export const isMobile = () => {
  let userAgent = navigator.userAgent.toLowerCase();
  let reg =
    /ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/;
  // 用 test 匹配浏览器信息
  if (reg.test(userAgent)) {
    console.log("前端是移动端");
    return true;
  } else {
    console.log("前端是pc端");
    return false;
  }
};