vue中判断设备是否移动端区分界面进入不同的路由

  mounted() {
    if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
      this.$router.push({name:'phonepage'})
      // return;
    }else{
      this.$router.push({name:'pcpage'})
      document.getElementsByTagName('body')[0].className = 'overflowhidden'
      // this.$refs.appidobj.style.backgroundImage = 'url(../../static/pcui/loading/img_bg.png)'
      // this.$refs.appidobj.style.backgroundSize = '100% 105%'
      // setTimeout(()=>{
      //   this.$refs.appidobj.style.backgroundImage = ''
      //   this.$refs.appidobj.style.backgroundSize = ''
      // },500)
    }
  },
原文地址:https://www.cnblogs.com/huayang1995/p/14898621.html