1.安裝需要的環境及vue-cli:
【node.js】
官方:http://nodejs.cn/download/ 下載安裝;
命令列輸入:node -v,檢查是否安裝成功;
【npm】
官網安裝node.js后,就已經自帶npm;
命令列輸入:npm -v,檢查是否安裝成功;
【cnpm】
命令列輸入:npm install -g cnpm --registry=https://registry.npm.taobao.org
命令列輸入:cnpm -v,檢查是否安裝成功;
【webpack】
命令列輸入:cnpm install webpack -g
命令列輸入:webpack -v,檢查是否安裝成功;
【vue-cli】
命令列輸入:cnpm install vue-cli -g
命令列輸入:vue -V,檢查是否安裝成功;
2.新建并初始化一個vue專案
【myvue】
新建一個檔案夾myvue,放置vue專案
【init專案】
命令列進入myvue上一級目錄,輸入:vue init webpack myvue
【初始化配置選擇】
? Target directory exists. Continue? (Y/n) y ——找到目標目錄,是否繼續? y
? Project name (myvue) —— 專案名(默認檔案名)
? Project description (A Vue.js project) ——專案描述(默認)
? Author wwb——專案作者
? Vue build (Use arrow keys) ——創建方式(選默認第一個)
> 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 - re
nder functions are required elsewhere
? Install vue-router? (Y/n)y —— 安裝路由? y
? Use ESLint to lint your code? (Y/n)n ——使用eslint檢測規則?n
? Set up unit tests (Y/n)n —— 安裝單元測驗?n
? Setup e2e tests with Nightwatch?n (Y/n) ——安裝e2e測?n
? Should we run `npm install` for you after the project has been created? (recommended) (Use arrow keys) ——專案創建后運行“npm install”?(選默認第一個即可)
> Yes, use NPM
Yes, use Yarn
No, I will handle that myself
【初始化完成】
To get started:
cd myvue
npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack
【運行專案】
命令列輸入:cd myvue
命令列輸入:npm run dev
【啟動成功】


【可能的報錯】
"Cannot find module 'webpack/bin/config-yargs"
【解決辦法】
命令列輸入:npm install webpack-cli -D
命令列輸入:npm update
命令列輸入:npm run dev
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/294962.html
標籤:其他
