项目 router 文件夹下的 index.js 中有两个路由,分别是 pc 端路由和移动端路由
export default new Router({
routes: [
{
path: '/',
redirect:'/pc-home'
},
// pc端的路由
{
path:'/pc-home',
name:'pc-home',
component:()=>import('@/components/pc/Home')
},
// 手机端的路由
{
path:'/phone-home',
name:'phone-home',
component:()=>import('@/components/phone/Home')
}
]
})
在 App.vue 中判断当前设备进行跳转路由
export default new Router({
routes: [
{
path: '/',
redirect:'/pc-home'
},
// pc端的路由
{
path:'/pc-home',
name:'pc-home',
component:()=>import('@/components/pc/Home')
},
// 手机端的路由
{
path:'/phone-home',
name:'phone-home',
component:()=>import('@/components/phone/Home')
}
]
})