适配双端的话是两套路由
在router/index.js里面更改routes的赋值就可以了
const routerPc = [
{
path: '/',
redirect: "/index"
},
{
path: '/index',
component: () =>
import('@/views/pc/index'),
}
]
const routerM = [
{
path: '/',
redirect: "/index"
},
{
path: '/index',
component: () =>
import('@/views/mobiLe/index')
}
]
var routes = []
let Adaptive = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
if (navigator.userAgent.match(Adaptive)) {
routes = routerM
} else {
routes = routerPc
}
const router = new Router({
mode: "hash",
routes
})
以上就是适配双端的路由了