我用两套Vue代码实现pc和移动端的切换,切换到移动端的网址是localhost:8080/move. html/,不能触发路由,请问怎么解决
我切换的方法是,如果是pc端,就用路由前置守卫window.location.href = '/move.html/'跳转到移动端页面
move.main.js文件代码:
import { createApp } from 'vue'
import Move from './Move.vue'
import ElementPlus from 'element-plus'
import router from '../move/move.router'
import 'element-plus/dist/index.css'
const app=createApp(Move)
app.use(router)
app.use(ElementPlus)
app.mount('#move')
move.router.js代码:
import { createRouter, createWebHistory } from "vue-router";
const test=()=>import('./page/Index.vue')
const router = createRouter({
history: createWebHistory(),
mode:'history',
routes: [
{
path: "/",
redirect:"/test"
},
{
path: "/test",
name:'test',
component:test
}
],
});