VUE 项目安装

第一步:安装 vue-cli

npm install -g @vue/cli-service-global

第二步:创建vue项目

vue create kekou //(kekou=>项目名称)

  

defalut(默认)  Manually(手动)  相比于默认选择,可口更倾向于选择手动添加(让我们下滑选中 Manually select features )

? Please pick a preset: Manually select features
? Check the features needed for your project: (Press <space> to select, <a> to toggle all, <i> to invert selection)
>(*) Babel // 将最新版的js语法(es6、es7)转换为现阶段浏览器可以兼容的js代码
 ( ) TypeScript // 使用ts语法
 ( ) Progressive Web App (PWA) Support //渐进式WEB应用 https://developer.mozilla.org/zh-CN/docs/Web/Progressive_web_apps
 (*) Router // vue 路由
 (*) Vuex // vue 中间键
 (*) CSS Pre-processors // css 预处理器 (Scss Sass stylus Less)
 (*) Linter / Formatter //代码规范标准
 ( ) Unit Testing //单元测试
 ( ) E2E Testing //e2e测试

  键盘上下箭头切换,空格选中。选择好后,回车确定;

? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) y 

是否使用history模式,history模式需要后台配置支持(参考文档:https://router.vuejs.org/zh/guide/essentials/history-mode.html#后端配置例子)。

? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default):
  Sass/SCSS (with dart-sass)  // dart-sass 编译模式
> Sass/SCSS (with node-sass) // node-sass 编译模式
  Less
  Stylus

选择预处理器 可口这边习惯选择scss;

? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)
? Pick a linter / formatter config: (Use arrow keys)
  ESLint with error prevention only  // 仅用于预防错误
  ESLint + Airbnb config  //Airbnb格式配置
  ESLint + Standard config //Standard格式配置
> ESLint + Prettier //Prettier 会自动美化代码,让每个人的代码风格达到一样


选择自己喜欢的编码分隔,可口这边选择的是Prettier。

? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)
? Pick a linter / formatter config: Prettier
? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)
>(*) Lint on save  // 保存时检测
 ( ) Lint and fix on commit  //执行eslint --fix(自动修复格式错误)或者 git commit (git代码提交) 时检测



? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)
? Pick a linter / formatter config: Prettier
? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)Lint on save
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? (Use arrow keys)
  In dedicated config files  // 独立文件放置
> In package.json // 存放在 package.json 文件中



? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)
? Pick a linter / formatter config: Prettier
? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)Lint on save
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json
? Save this as a preset for future projects? (y/N) y // 是否记录一下以便下次继续使用这套配置



? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-processors, Linter
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)
? Pick a linter / formatter config: Prettier
? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)Lint on save
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json
? Save this as a preset for future projects? Yes
? Save preset as: kekou  //给你这次的配置取一个名称 下次重新创建项目时,你会发现在在default(默认)与Manually(手动)上面会多了个kekou(你这次配置的名称)



​



到这里就项目就创建完了。如果想远程使用这次的配置,或分享给他人,可参考文档:https://cli.vuejs.org/zh/guide/plugins-and-presets.html#%E8%BF%9C%E7%A8%8B-preset