vue通過(NGINX)部署在子目錄或者二級目錄實踐
1、1、修改 router/index.js
添加一行
base: 'report',
2、然後修改 config/index.js
增加一行
const assetsPublicPath = '/admin/'
然後修改 下面兩處 assetsPublicPath 的值爲定義的變量
然後本地就可以訪問了.
Nginx像下面部署:
server {
listen 80;
server_name xxx.com;
root /navy/web/dist;
location /current {
proxy_pass http://47.100.62.xx:8086;
}
location /wreport {
root /navy/web/dist;
index index.html index.html;
try_files $uri $uri/ /index.html;
}
}
關鍵一點是要將dist文件夾下面index.html的文件中的src的report這個都刪掉,一共四處,刪掉就行.
圖中紅色箭頭部分就是去掉/report的地方.去掉之後,
nginx -s reload
即可在nginx 的部署的服務器上進行訪問.
如果還有什麼問題,請掃碼關注公衆號:架構師Plus,進行提問交流