vue-cli2.x与vue-cli3.x脚手架,初始化项目图文讲解!

首先区要分脚手架版本:若安装了最新版本脚手架,想用老版本脚手架,创建vue2项目,需要拉取vue-cli2.x的模板才可以用!!

拉取模板命令: npm install @vue/cli-init -g

创建Vue2的初始化方式

vue init webpack vue-cli2test

1、项目名称:默认

? Project name vue-cli2test

2、项目描述:默认

? Project description A Vue.js project

3、作者信息:默认读取git信息

? Author baijunguo <guobj@jixingkeji.net>

4、模板渲染:runtime-only,性能高,代码量少,项目会轻6kb)

runtime-compiler:template > ast(抽象语法树) > render(函数) > 虚拟dom > 真实dom

runtime-only:render(函数) > 虚拟dom > 真实dom

? Vue build standalone

5、安装路由:y

? Install vue-router? Yes

6、代码格式校验:n

? Use ESLint to lint your code? No

7、单元测试:n

? Set up unit tests No

8、端到端测试:n

? Setup e2e tests with Nightwatch? No

9、安装方式:npm

? Should we run `npm install` for you after the project has been created? (recommended) npm

在这里插入图片描述
回车…巴拉巴拉开始初始化
在这里插入图片描述
看到Project initialization finished!项目初始化完成

创建Vue3的初始化方式(新版本脚手架创建Vue2也是同理)

输入创建Vue3项目命令

E:\>vue create vue-3admin		

默认配置与手动选择功能

Vue CLI v4.5.13
? Please pick a preset: (Use arrow keys)
> Default ([Vue 2] babel, eslint)				Vue2默认配置
  Default (Vue 3) ([Vue 3] babel, eslint)		Vue3默认配置
  Manually select features				  		这里演示手动选择功能,不用后续安装路由,状态管理..

空格选中,安装功能

Vue CLI v4.5.13
? Check the features needed for your project:
>(*) Choose Vue version							Vue版本选择
 (*) Babel										ES6转ES5
 ( ) TypeScript								
 ( ) Progressive Web App (PWA) Support
 (*) Router										路由
 (*) Vuex										状态管理
 (*) CSS Pre-processors							CSS预处理器
 ( ) Linter / Formatter
 ( ) Unit Testing
 ( ) E2E Testing

版本选择:3.x

Vue CLI v4.5.13
? Check the features needed for your project: Choose Vue version, Babel, Router, Vuex, CSS Pre-processors
? Choose a version of Vue.js that you want to start the project with
  2.x
> 3.x

路由的history 模式:n

Vue CLI v4.5.13
? Check the features needed for your project: Choose Vue version, Babel, Router, Vuex, CSS Pre-processors
? Choose a version of Vue.js that you want to start the project with 3.x
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) n

Sass/SCSS (with node-sass)

Vue CLI v4.5.13
? Check the features needed for your project: Choose Vue version, Babel, Router, Vuex, CSS Pre-processors
? Choose a version of Vue.js that you want to start the project with 3.x
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? 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

In package.json

Vue CLI v4.5.13
? Check the features needed for your project: Choose Vue version, Babel, Router, Vuex, CSS Pre-processors
? Choose a version of Vue.js that you want to start the project with 3.x
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)


? Where do you prefer placing config for Babel, ESLint, etc.?
  In dedicated config files
> In package.json

将此保存为将来项目的预设?:n

Vue CLI v4.5.13
? Check the features needed for your project: Choose Vue version, Babel, Router, Vuex, CSS Pre-processors
? Choose a version of Vue.js that you want to start the project with 3.x
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with node-sass)


? Where do you prefer placing config for Babel, ESLint, etc.? In package.json
? Save this as a preset for future projects? (y/N) n

成功创建Vue项目,Successfully created project vue-3admin.

Vue CLI v4.5.13
✨  Creating project in E:\vue-3admin.
�  Initializing git repository...
⚙️  Installing CLI plugins. This might take a while...


> core-js@3.18.2 postinstall E:\vue-3admin\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"


> ejs@2.7.4 postinstall E:\vue-3admin\node_modules\ejs
> node ./postinstall.js

added 1220 packages from 636 contributors in 20.652s

81 packages are looking for funding
  run `npm fund` for details

�  Invoking generators...
�  Installing additional dependencies...


> node-sass@4.14.1 install E:\vue-3admin\node_modules\node-sass
> node scripts/install.js

Cached binary found at C:\Users\疾风亦有归途\AppData\Roaming\npm-cache\node-sass\4.14.1\win32-x64-72_binding.node

> node-sass@4.14.1 postinstall E:\vue-3admin\node_modules\node-sass
> node scripts/build.js

Binary found at E:\vue-3admin\node_modules\node-sass\vendor\win32-x64-72\binding.node
Testing binary
Binary is fine
added 110 packages from 73 contributors in 7.418s

85 packages are looking for funding
  run `npm fund` for details

⚓  Running completion hooks...

�  Generating README.md...

�  Successfully created project vue-3admin.
�  Get started with the following commands:

 $ cd vue-3admin
 $ npm run serve


E:\>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柏君~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值