怎樣創建一個 Vue CLI 項目
最近更新時間 2020-03-08 10:29:48
Vue CLI 需要 Node.js 8.9 或更高版本 (推薦 8.11.0+)。
1. 安裝 VUE 包
可以使用下列任一命令安裝 VUE 包:
npm install -g @vue/cli
或者
yarn global add @vue/cli
2. 創建一個項目
運行以下命令來創建一個新項目:
vue create hello-world
Vue CLI v4.2.3 ? Please pick a preset: (Use arrow keys) ❯ default (babel, eslint) Manually select features
你會被提示選取一個 preset。你可以選默認的包含了基本的 Babel + ESLint 設置的 preset,也可以選“手動選擇特性”來選取需要的特性。 直接回車按默認值設置。
Vue CLI v4.2.3 ✨ Creating project in /vuecli/hello-world. 🗃 Initializing git repository... ⚙️ Installing CLI plugins. This might take a while... yarn install v1.17.3 info No lockfile found. [1/4] 🔍 Resolving packages... success Saved lockfile. ✨ Done in 62.11s. 🚀 Invoking generators... 📦 Installing additional dependencies... yarn install v1.17.3 [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 🔨 Building fresh packages... success Saved lockfile. ✨ Done in 22.46s. ⚓ Running completion hooks... 📄 Generating README.md... 🎉 Successfully created project hello-world. 👉 Get started with the following commands: $ cd hello-world $ yarn serve
3. 啟動項目
cd hello-world
yarn serve
yarn run v1.17.3 $ vue-cli-service serve INFO Starting development server... 98% after emitting CopyPlugin DONE Compiled successfully in 3033ms 10:27:09 AM App running at: - Local: http://localhost:8080/ - Network: http://192.168.1.13:8080/ Note that the development build is not optimized. To create a production build, run yarn build.