安裝腳手架
npm install -g vue-cli@4.2.3$ vue create toutiao-m
Vue CLI v4.2.3
? Please pick a preset:
default (babel, eslint)
> Manually select features
default:默認勾選 babel、eslint蜜宪,回車之后直接進入裝包
manually:自定義勾選特性配置,選擇完畢之后圃验,才會進入裝包
選擇第 2 種:手動選擇特性澳窑,支持更多自定義選項
? Please pick a preset: Manually select features
? Check the features needed for your project:
(*) Babel
( ) TypeScript
( ) Progressive Web App (PWA) Support
(*) Router
(*) Vuex
(*) CSS Pre-processors
>(*) Linter / Formatter
( ) Unit Testing
( ) E2E Testing
分別選擇:
Babel:es6 轉(zhuǎn) es5
Router:路由
Vuex:數(shù)據(jù)容器供常,存儲共享數(shù)據(jù)
CSS Pre-processors:CSS 預(yù)處理器,后面會提示你選擇 less麻裁、sass源祈、stylus 等
Linter / Formatter:代碼格式校驗
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) n
是否使用 history 路由模式,這里輸入 n 不使用
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default):
Sass/SCSS (with dart-sass)
Sass/SCSS (with node-sass)
> Less
Stylus
選擇 CSS 預(yù)處理器手销,這里選擇我們熟悉的 Less
? Pick a linter / formatter config:
ESLint with error prevention only
ESLint + Airbnb config
> ESLint + Standard config
ESLint + Prettier
選擇校驗工具锋拖,這里選擇 ESLint + Standard config
? Pick additional lint features:
(*) Lint on save
>(*) Lint and fix on commit
選擇在什么時機下觸發(fā)代碼格式校驗:
Lint on save:每當保存文件的時候
Lint and fix on commit:每當執(zhí)行git commit
提交的時候
這里建議兩個都選上祸轮,更嚴謹。
? Where do you prefer placing config for Babel, ESLint, etc.? (Use arrow keys)
> In dedicated config files
In package.json
Babel柄错、ESLint 等工具會有一些額外的配置文件鄙陡,這里的意思是問你將這些工具相關(guān)的配置文件寫到哪里:
In dedicated config files:分別保存到單獨的配置文件
In package.json:保存到 package.json 文件中
這里建議選擇第 1 個冕房,保存到單獨的配置文件,這樣方便我們做自定義配置给僵。
? Save this as a preset for future projects? (y/N) N
這里里是問你是否需要將剛才選擇的一系列配置保存起來帝际,然后它可以幫你記住上面的一系列選擇,以便下次直接重用蹲诀。
這里根據(jù)自己需要輸入 y 或者 n,我這里輸入 n 不需要脯爪。
? Creating project in C:\Users\LPZ\Desktop\topline-m-fe89\topline-m-89.
? Initializing git repository...
? Installing CLI plugins. This might take a while...
[ ........] - extract:object-keys: sill extract json5@2.1.1
向?qū)渲媒Y(jié)束痕慢,開始裝包。
安裝包的時間可能較長掖举,請耐心等待......
? Running completion hooks...
? Generating README.md...
? Successfully created project topline-m-89.
? Get started with the following commands:
$ cd topline-m
$ npm run serve
安裝結(jié)束塔次,命令提示你項目創(chuàng)建成功,按照命令行的提示在終端中分別輸入:
進入你的項目目錄
cd toutiao-webapp
啟動開發(fā)服務(wù)
npm run serve