只需要在vue-router中写两个routes表,再通过判断设备切换路由表即可
const routesPC = [{ //默认路径
path: '*',
redirect: '/home',
},
{
path: '/home',
name: 'Home',
component: Home,
meta: {
title: "首页"
}
},
]
const routesM = [ //移动端
{ //默认路径
path: '*',
redirect: '/m',
},
{
path: '/m',
name: 'm',
component: m
},
]
var routes = []
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
routes = routesM
} else {
routes = routesPC
}