Vue把路由修改成history 后,通过刷新后报500错误问题,解决方案

第一:在路由文件中配置:src/router/index.js 

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)

export default new Router({
    mode:"history",
    routes: [{

第二步: 在服务器端,进行访问配置:nginx 配置方案

location / {
    try_files $uri $uri/ /index.html;
}

 

更多方案,可以看官网指南:https://router.vuejs.org/zh/guide/essentials/history-mode.html

posted @ 2022-04-26 10:01  OneNightStand  阅读(1140)  评论(0编辑  收藏  举报