Bootstrap

判断是H5是PC

// 在Vue组件中使用
computed: {
    isMobile() {
        const userAgentInfo = navigator.userAgent;
        const agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
        for (let i = 0; i < agents.length; i++) {
            if (userAgentInfo.indexOf(agents[i]) > -1) {
                return true; // 移动端
            }
        }
        return false; // PC端
    }
}

方式二

  //监听打开该项目的系统
  detectDeviceType {
  const machineType = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? 'Mobile' : 'Desktop'
   console.log('isH5-machineType',machineType)
   if (machineType === 'Mobile') {
      console.log('isH5-移动端')
    } else {
      console.log('isH5-Pc端')
    }
   },
;