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項目。