import { createRouter, createWebHistory } from 'vue-router' import errorPage from '@/router/error/index.js' import h5 from '@/router/h5/router.js' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ ...errorPage, ...h5], }) router.beforeEach((to, from, next) => { if (!to.matched.length) { if (to.path === '/') { next({ path: '/error/404', query: { errorUrl: to.path } }) } } else { next() } }) export default router