server
{
listen 80;
server_name xxx.com;
access_log /usr/local/src/admin/log/access.log;
error_log /usr/local/src/admin/log/error.log;
location / {
root /usr/local/src/admin;
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html;
}
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
}