1. 查看自己是否安装过 node.js
node -v
npm -v
2. 在node安装的盘全局安装vue 脚手架(vue-cli)
npm install -g @vue/cli(@vue/cli-init 这种情况 是在创建Vue项目的时候 出现错误提示 让输入才再次输入就可以了)
3. 检查vue-cli有没有安装成功
vue --version
4.切换到要创建项目的目录下,输入(除特殊情况外都是点击空格确认)
vue init webpack 文件名(这个文件名是自己要输入的文件名 不能包含中文)
Project name (webDemo) 项目名称(默认的是文件名称,不能有中文)
Project description (A Vue.js project) 项目的介绍,可以任意写,也可以有中文,默认为空
Author (xxx <xxxxxx1114@qq.com>) 项目作者
Vue build (Use arrow keys) 打包Vue文件的权限用户,选第一个全部用户都可以
Install vue-router? (Y/n) 是否安装VUERouter 输入Y
Use ESLint to lint your code? (Y/n) 是否使用ESlint严格语法校验(选N,如果你不知道什么是严格,选N就对了)
Set up unit tests (Y/n) 是否创建单元测试 选N
Setup e2e tests with Nightwatch? (Y/n) 是否创建单元测试环境 选N
Should we run `npm install` for you after the project has been created? (recommended) (Use arrow keys) 运行和打包项目的命令行 选Npm
5. 切换到创建好的项目目录下
cd 文件名
6.启动项目
npm run dev
默认创建Vue2.0项目
或者输入
vue create 文件名
Please pick a preset: (Use arrow keys) 选择要创建的项目配置,选第三个 自定义配置
Check the features needed for your project: (Press <space> to select, <a> to toggle all, <i> to invert selection, and
<enter> to proceed) 请选择你的自定义配置 按响应的数字键选择/取消选择响应的选项
Choose a version of Vue.js that you want to start the project with (Use arrow keys) 请选择要创建的Vue版本 2.0 就选择2.x 3.0选择3.x
Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) 是否使用history的路由模式 选择Y
Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): (Use arrow keys) 选择css的预处理程序,会使用SASS语法的选择sass/scss 会使用less的选择less 会使用stylus的选择stylus 都会使用的 随便
Where do you prefer placing config for Babel, ESLint, etc.? (Use arrow keys) eslint你想配置在哪里 选择 in package.json
Save this as a preset for future projects? 是否为你把eslint配置在项目中 选择N
5. 切换到创建好的项目目录下
cd 文件名
6.启动项目
npm run dev