1、需要使用 npm 安装 Vue CLI ,npm 集成在 Node.js 中的,安装参见文章:安装 Node.js 使用 npm
2、安装 Vue CLI 的命令
npm install -g @vue/cli
查看安装版本,目前安装的版本是:@vue/cli 4.3.0
vue --version
3、创建一个项目
1)执行创建命令
首先进入到工作文件夹(workspace),然后执行如下命令创建项目
vue create test-vue
2)选择手动设置
Vue CLI v4.3.0
? Please pick a preset:
❯ default (babel, eslint)
Manually select features
3)选择需要创建的内容
Vue CLI v4.3.0
? 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:一个javascript转译器,将最新版的js语法(es6、es7)转换为现阶段浏览器可以兼容的js代码
TypeScript:作用有些类似于babel,拥有类型检查能力和面向对象新特征。
PWA:渐进式WEB应用
Router:路由,设置url,使不同的url显示不同的页面
Vuex:作用类似于全局对象,但是并不完全相同。
CSS Pre-processors:css预处理器
Linter / Formatter:代码规范标准
Unit Testing:单元测试
E2E Testing:e2e测试
4)选择相应的配置
Vue CLI v4.3.0
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Linter
? Use history mode for router? (Requires proper server setup for index fallback
in production) Yes
? Pick a linter / formatter config: Standard
? Pick additional lint features: Lint on save
? Where do you prefer placing config for Babel, ESLint, etc.? In package.json
? Save this as a preset for future projects? (y/N)
5)创建完成
🎉 Successfully created project test-vue.
👉 Get started with the following commands:
$ cd test-vue
$ npm run serve
Vue CLI的详细介绍可查阅:https://cli.vuejs.org/zh/guide