一,脚手架安装css
Node 版本要求 Vue CLI 须要 Node.js 8.9 或更高版本 (推荐 8.11.0+)。你能够使用 nvm 或 nvm-windows 在同一台电脑中管理多个 Node 版本。
1,全局安装Vue CLIvue
npm install -g @vue/cli # OR yarn global add @vue/cli
安装以后,使用如下命令查看安装是否正确node
vue --version
2,快速建立一个CLI项目vuex
vue create cli_test
此时会出现如下安装选项:npm
PS E:\workspace\demo> vue create cli_test Vue CLI v3.9.2 ? Please pick a preset: useLessDefault (vue-router, vuex, less, babel, eslint) //上一次我保存的默认配置,第一次是没有的 default (babel, eslint) //默认配置建立 > Manually select features //自定义配置选项,建议选择
注:按上、下健切换选项,按空格键选择选项,按i键反选json
Vue CLI v3.9.2 ? Please pick a preset: Manually select features ? Check the features needed for your project: (Press <space> to select, <a> to t ? Check the features needed for your project: (Press <space> to select, <a> to t ? Check the features needed for your project: (Press <space> to select, <a> to t ? Check the features needed for your project: (Press <space> to select, <a> to t ? Check the features needed for your project: (*) Babel // 是否使用babel作转义 ( ) TypeScript // 是否使用class风格的组件语法 ( ) Progressive Web App (PWA) Support // 支持PWA (*) Router // 安装使用路由Router (*) Vuex // 安装使用Vuex状态管理,简单项目不建议使用安装 (*) CSS Pre-processors // 选择CSS 预处理类型 (*) Linter / Formatter // 选择Linter / Formatter规范类型 >(*) Unit Testing // 选择Unit测试方式 ( ) E2E Testing // 选择E2E测试方式
注:能够先不选择,后期若是用到,再手动添加便可windows
Vue CLI v3.9.2 ? Please pick a preset: Manually select features ? Check the features needed for your project: (Press <space> to select, <a> to t ? Check the features needed for your project: (Press <space> to select, <a> to t ? Check the features needed for your project: (Press <space> to select, <a> to t ? Check the features needed for your project: (Press <space> to select, <a> to t ? Check the features needed for your project: Babel, Router, Vuex, CSS Pre-proce ssors, Linter, Unit ? Use history mode for router? (Requires proper server setup for index fallback ? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) n
注:根据本身的开发习惯选择预处理浏览器
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported ? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported ? 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
? 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: (Press <space> to select, <a> to toggle all, <i > to invert selection) >(*) Lint on save //保存代码时校验 ( ) Lint and fix on commit (requires Git)// fix和commit时候检查
? Pick a unit testing solution: Mocha + Chai > Jest
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? (Use arro w keys) > In dedicated config files In package.json
? Save this as a preset for future projects? (y/N)y
? Save this as a preset for future projects? Yes ? Save preset as: myCli
added 59 packages from 101 contributors, updated 3 packages, moved 13 packages a nd audited 42942 packages in 30.434s found 64 low severity vulnerabilities run `npm audit fix` to fix them, or `npm audit` for details ⚓ Running completion hooks... � Generating README.md... � Successfully created project cli_test. � Get started with the following commands: $ cd cli_test $ npm run serve
cd cli_test npm run serve 浏览器输入http://localhost:8080
npm run build
执行后,会多一个dist的目录,直接把这个目录放到服务器Nginx下就能够访问了
CLI默认配置只是简单的项目框架,更多配置、组件封装请参考我其它的文章!sass