H5 页面刷新404

发布时间 2023-07-28 16:11:30作者: 法子

参考:https://blog.csdn.net/weixin_44917334/article/details/129387658

history 模式由createWebHistory改为createWebHashHistory

import { createRouter, createWebHistory,createWebHashHistory } from 'vue-router'

import HomeView from '../views/HomeView.vue'
import LoginView from '../views/LoginView.vue'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      meta: {
        title: '首页'
      }
    },
    {
      path: '/login',
      name: 'login',
      component: LoginView,
      meta: {
        title: '登录'
      }
    }
  ]
})