当前位置:   article > 正文

vue路由history模式刷新页面出现404问题_vue history 模式 {"msg":"not found","code":404}

vue history 模式 {"msg":"not found","code":404}

vue hash模式下,URL中存在’#’,用’history’模式就能解决这个问题。但是history模式会出现刷新页面后,页面出现404。解决的办法是用nginx配置一下。
nginx的配置文件中修改

方法一:

location /{
root /data/nginx/html;
index index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*) /index.html last;
break;
}
}
方法二:
vue.js官方教程里提到的https://router.vuejs.org/zh/g…

server {
listen 8081;#默认端口是80,如果端口没被占用可以不用修改
server_name myapp.com;
root D:/vue/my_app/dist;#vue项目的打包后的dist
location / {
try_files $uri KaTeX parse error: Expected 'EOF', got '#' at position 14: uri/ @router;#̲需要指向下面的@router否… /index.html last;
}
#…其他部分省略
}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/619403
推荐阅读
相关标签
  

闽ICP备14008679号