vue-cli
構建項目骨架php
npm install
安裝依賴包html
npm run dev
開發調試代碼vue
npm run build
生產環境代碼vue-cli
執行第4步完成後,一般有以下小提示npm
Tip: built files are meant to be served over an HTTP server. Opening index.html over file:// won't work.服務器
即這些生產環境代碼文件(在執行build基於開發環境代碼生成),須要放在http服務器上纔會有效。ui
解決
須要一個簡易的零配置的http服務器,推薦安裝調試
npm install http-server -gcode
http-server [path] [options]server
它的用法相似於php的內置服務器php -s ,
好比你的生產代碼位於當前dist目錄下,你能夠這樣:
http-server ./dist
此時訪問 localhost:8080 的代碼,其實際上就是至關訪問線上生產環境代碼