vue 项目上线后刷新页面404

项目上线后,刷新页面报错404 not Found,本地开发及调试可是好好的呀,找了一些资料,这里总结下

1、设置history模式(默认是hash模式,不仅不美观而且还不会重载页面)

在router中的index.js配置文件中把mode:"history"

2、我这边服务器使用的是nginx,配置下nginx即可(如果不配置,当我们访问http://域名/home路径时,就会返回404)

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

别忘了最后重启下nginx

 

posted @ 2021-03-11 10:55  叫我汤先森  阅读(552)  评论(0)    收藏  举报