zoukankan      html  css  js  c++  java
  • 判断移动端还是PC端

    router.js
     1 routes: [
     2         {
     3             name: 'pc', path: '/pc', component: pc, redirect: '/pc/homePage', meta: {title: 'pc端'},
     4             children:
     5                 [
     6                     {name: 'homePage', path: 'HomePage', component: HomePage, meta: {title: '首页'}}, 
     7                 ]
     8         },
     9         {name: 'mobile', path: '/mobile', component: mobile,redirect: '/mobile/mobileHomePage', meta: {title: 'web首页'},
    10             children:[
    11                 {name: 'mobileHomePage', path: 'mobileHomePage', component: mobileHomePage, meta: {title: '首页'}},
    12             ]
    13         }
    14     ]

    app.vue

     1  
     2  
     3 mounted() {
     4             if (this._isMobile()) {
     5                 this.$router.replace('/mobile');
     6             } else {
     7                 this.$router.replace('/pc');
     8             }
     9         },
    10         methods: {
    11             _isMobile() {
    12                 let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
    13                 return flag;
    14             }
    15         }

  • 相关阅读:
    lesson4Embedding-fastai
    lesson3 overfitting -fastai
    cell-augmented
    ROI-Align解决方案
    软件安装
    lesson1-fastai
    mask-rcnn
    代码basic讲解
    skearn/pandas
    HDU1087上升子序列的最大和
  • 原文地址:https://www.cnblogs.com/xiaozhu-zhu/p/11946907.html
Copyright © 2011-2022 走看看