1、前端vue需要设置 mode 为 history 模式
2、后端nginx 配置
1)、同一个配置文件下:
# 后端服务 配置
server {
listen 8082;
server_name _;
location /static/ {
alias /root/服务器上的项目名/vue/dist/static/;
}
# 后端 uwsgi 配置
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9999;
}
error_page 497 https://$server_name:8082$request_uri;
}
# 前端 vue 配置, 在浏览器访问: 地址 + :8080
server {
listen 8080;
server_name _;
location / {
root /root/服务器上的项目名/vue/dist;
index index.html;
try_files $uri $uri/ @router;
}
location @router {
rewrite ^.*$ /index.html last;
}
}