Vue路由模式设置为history,nginx的配置
1. Vue的路由模式设置为history
const router = new Router({
mode: 'history',
routes: routes,
})
2. nginx
的配置,主要就是添加try_files $uri $uri/ /index.html;
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 12345;
server_name localhost;
location / {
try_files $uri $uri/ /index.html;
root
D:\My-Project\Vue_Project_Admin\dist;
index index.html index.htm;
}
}
}