1、vue项目router设置为history模式
const router = new VueRouter({
mode: "history",
base: process.env.BASE_URL,
routes,
});
2、服务器nginx.config修改配置
location / { root /usr/share/nginx/dist; index index.html index.htm; try_files $uri $uri/ /; }
3、开启gzip压缩
gzip on; gzip_min_length 5k; gzip_buffers 4 16k; #gzip_http_version 1.0; gzip_comp_level 3; gzip_types application/javascript application/octet-stream text/css image/png; gzip_vary on;
*静态文件服务
server {
listen 8080;
charset utf-8;
root /usr/share/nginx/download;
location / {
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
}