使用vue cli 构建项目
- 先检查是否安装 node.js和 npm(node -v npm -v),如果没有安装请先安装
- 安装vue cli
npm install -g @vue/cli
- 创建项目名称
vue create 项目名称
- 选择 手动配置 Manually select features (上下键控制)
Vue CLI v5.0.8
? Please pick a preset: (Use arrow keys)
❯ n ([Vue 2] babel, router)
Default ([Vue 3] babel, eslint)
Default ([Vue 2] babel, eslint)
Manually select features
- 选择 Babel 转码器 Router, Vuex(上下键控制 空格选择 )
? Check the features needed for your project: (Press <space> to select, <a> to
toggle all, <i> to invert selection, and <enter> to proceed)
❯◉ Babel
◯ TypeScript
◯ Progressive Web App (PWA) Support
◯ Router
◯ Vuex
◯ CSS Pre-processors
◉ Linter / Formatter
◯ Unit Testing
◯ E2E Testing
- 选择版本 2.x(3.x 有部分不兼容)
? Choose a version of Vue.js that you want to start the project with (Use arrow
keys)
❯ 3.x
2.x
- 是否在路由中 开启 history模式,选择 No
? Use history mode for router? (Requires proper server setup for index fallback
in production) (Y/n)
- 你想把你的配置文件放在一个独立的配置文件中,还是放到package.json中?选择 In package.json(两者区别不大)
? Where do you prefer placing config for Babel, ESLint, etc.? (Use arrow keys)
❯ In dedicated config files
In package.json
- 是否保存以上设置,方便下次选择,选择 No
? Save this as a preset for future projects? (y/N)
最后等待项目构建完成即可