vue/cli 脚手架用法(Vue2)

119 阅读1分钟
  1. 全局安装:yarn global add @vue/cli

  2. 创建目录: vue create路径(路径可以用.点) 如 vue create demo即在当前目录下创建demo文件作为vue的文件夹

  3. 选择使用哪些配置

    • ? Please pick a preset: (Use arrow keys)

    bj-132 ([Vue 2] less, babel)

    bj132 ([Vue 2] less, babel)

    Default ([Vue 2] babel, eslint)

    Default (Vue 3) ([Vue 3] babel, eslint)

    Manually select features

    一般选择自己配置,即Manually select features 可以看你喜欢哪个,但是建议自己配置比较方便,这里是vue2的配置方法

    • ? Check the features needed for your project:

    ( * ) Choose Vue version

    ( * ) Babel

    ( ) TypeScript

    ( ) Progressive Web App (PWA) Support

    ( ) Router

    ( ) Vuex

    ( * ) CSS Pre-processors

    ( * ) Linter / Formatter

    ( * ) Unit Testing

    ( ) E2E Testing

    • Choose a version of Vue.js that you want to start the project with (Use arrow keys)

    2.x 3.x

    我们先选择2.x 用Vue2

    • Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): (Use arrow keys)

    Sass/SCSS (with dart-sass)

    Sass/SCSS (with node-sass)

    Less Stylus

    看你选择什么语言 node-sass过时了,不需要,其他都可以

    • Pick a linter / formatter config: (Use arrow keys)

    ESLint with error prevention only

    ESLint + Airbnb config

    ESLint + Standard config

    ESLint + Prettier

    选择第一个

    • Pick additional lint features:

    ( ) Lint on save

    ( * ) Lint and fix on commit

    提交的时候修改和查找

    • Pick a unit testing solution:

    Mocha + Chai

    Jest

    选择Jest

    • Where do you prefer placing config for Babel, ESLint, etc.? (Use arrow keys)

    In dedicated config files In package.json

    选择第一个,把文件分装,不要装在一个文件中

    最后一个不保存配置

  4. 进入目录,运行yarn serve开启webpack-dev-server

  5. 用 WebStorm或VScode打开项目开始CRM

  6. 进入@vue/cli官网看看目录