1、vue-cli新建模板項目
準備
在使用vue-cli新建項目前。請確保你已經安裝了Node.js,vue和vue-cli。
步驟:
cd 目錄(要把項目放在哪個目錄)
vue init webpack pname(你的項目名字)
Project description (A Vue.js project) vue-cli新建項目(項目描述)
Author (作者)
Vue build
❯ Runtime + Compiler: recommended for most users
Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere
Install vue-router? (Y/n) 是否使用 vue-router,Y
Use ESLint to lint your code? (Y/n) 是否使用ESLint,Y
Pick an ESLint preset (Use arrow keys)
❯ Standard (https://github.com/feross/standard)
Airbnb (https://github.com/airbnb/javascript) none (configure it yourself)
Setup unit tests with Karma + Mocha? (Y/n) 是否需要單元測試,N
Setup e2e tests with Nightwatch? (Y/n) 是否需要單元測試,N
-
Should we run `npm install` for you after the project has been created? (recom mended) ❯ Yes, use NPM 自動運行 npm install 安裝依賴 Yes, use Yarn No, I will handle that myself
npm run dev 本地運行
結果
瀏覽器打開 http://localhost:8080