最近在做一个电商的项目,里面有平台端和商家端以及用户端,那么这么多Vue项目如何部署到服务器呢?
此时会生成一个文件
我上传的位置:
多加几个location即可
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html/dist/; index index.html index.htm; try_files $uri $uri/ @router; index index.html; } #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件 location @router { # #因此需要rewrite到index.html中,然后交给路由再处理请求资源 rewrite ^.*$ /index.html last; } location /admin { alias /usr/local/nginx/admin/dist; index index.html index.htm; try_files $uri $uri/ @router; index index.html; } #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的 location @router { # #因此需要rewrite到index.html中,然后交给路由再处理请求资源 try_files $uri $uri/ @router; index index.html; } #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体>的文件 location @router { # #因此需要rewrite到index.html中,然后交给路由再处理请求资源 rewrite ^.*$ /index.html last; }