1,假設你要訪問的項目名稱爲‘hms’html
2,在Tomcat的webapps下建立hms文件夾,web
3,配置config/index.js文件,設置assetsPublicPath: '/hms/'npm
(解釋:這裏改成這個配置以後,最後編譯產生的index.html中相關路徑也會帶上‘/hms’,不會報404的錯誤了)app
4,在項目運行「npm run build:prod」命令,生成dist文件夾,dist文件夾中包含static和index.htmlwebapp
5,將dist文件夾中static和index.html複製到Tomcat中webapps的hms文件夾中ui
6,啓動Tomcat,ip:port/hms,例如:http://localhost:8081/hms/便可訪問到Vue項目。htm