1. 程式人生 > >vue專案如何部署到Tomcat中

vue專案如何部署到Tomcat中

1,假設你要訪問的專案名稱為‘hms’

2,在Tomcat的webapps下建立hms資料夾,

3,配置config/index.js檔案,設定assetsPublicPath: '/hms/'

    (解釋:這裡改為這個配置之後,最後編譯產生的index.html中相關路徑也會帶上‘/hms’,不會報404的錯誤了)

4,在專案執行“npm run build:prod”命令,生成dist資料夾,dist資料夾中包含static和index.html

5,將dist資料夾中static和index.html複製到Tomcat中webapps的hms資料夾中

6,啟動Tomcat,ip:port/hms,例如:http://localhost:8081/hms/即可訪問到Vue專案。