1、需要NodeJS环境支持,此处省略NodeJS安装

2、使用NPM命令安装CLI包

vue-cli是npm.上的一个全局包,使用npm install 命令,即可方便的把它安装到自己的电脑上:

npm install -g @vue/cli

命令输出:

C:\Users\Administrator>npm install -g @vue/cli
npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead
npm WARN deprecated subscriptions-transport-ws@0.9.19: The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md
npm WARN deprecated apollo-cache-control@0.14.0: The functionality provided by the `apollo-cache-control` package is built in to `apollo-server-core` starting with Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#cachecontrol for details.
npm WARN deprecated graphql-extensions@0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/
npm WARN deprecated apollo-tracing@0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#tracing for details
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
C:\Users\Administrator\AppData\Roaming\npm\vue -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\@vue\cli\bin\vue.js > core-js-pure@3.22.3 postinstall C:\Users\Administrator\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}" Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library! The project needs your help! Please consider supporting of core-js:
> https://opencollective.com/core-js
> https://patreon.com/zloirock
> bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -) > @apollo/protobufjs@1.2.2 postinstall C:\Users\Administrator\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\@apollo\protobufjs
> node scripts/postinstall npm WARN node-fetch@2.6.7 requires a peer of encoding@^0.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.5.7 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.5.7 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself. + @vue/cli@5.0.4
added 883 packages from 531 contributors in 49.297s C:\Users\Administrator>

3、使用CLI命令创建项目

指定项目名称(demo-first):

vue create demo-first

选择初始化模板种类:

这里选择手动配置

Vue CLI v5.0.4
? Please pick a preset: (Use arrow keys) -- 使用方向键进行选择
Default ([Vue 3] babel, eslint) -- Vue3 项目 配置ESlint 和Babel加载器
Default ([Vue 2] babel, eslint) -- Vue2 项目 配置ESlint 和Babel加载器
> Manually select features -- 手动选择特性

选择需要安装的组件和插件支持

勾选Babel加载器和CSS预处理器

Vue CLI v5.0.4
? Please pick a preset: Manually select features
? Check the features needed for your project:
(
Press <space> to select, -- 按空格选中
<a> to toggle all, -- 按A全选
<i> to invert selection, -- 按i反选
and <enter> to proceed -- 按回车执行
)
>(*) Babel -- Babel加载器
( ) TypeScript -- TS脚本
( ) Progressive Web App (PWA) Support -- 渐进式WEB框架
( ) Router -- Vue路由配置
( ) Vuex -- Vue叉 集中缓存配置
(*) CSS Pre-processors -- CSS样式预处理器 LESS、SASS
( ) Linter / Formatter -- 语法限制
( ) Unit Testing -- 单元测试
( ) E2E Testing -- E2E测试

版本选择单独拎出来了,这里选择Vue2版本

 ? Choose a version of Vue.js that you want to start the project with
3.x
> 2.x

CSS预处理器的选择:

? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): (Use arrow keys)
> Sass/SCSS (with dart-sass)
Less
Stylus

配置文件的管理方式选择:

选择独立配置文件,不要选择集中在package.json中管理

一个组件对应一个配置文件

? Where do you prefer placing config for Babel, ESLint, etc.? (Use arrow keys)
> In dedicated config files -- 独立配置文件
In package.json -- 统一在package.json

 

最后是否保存上述选择作为一个自定义创建模板

方便下次创建时使用

# 是否保存这些预设作为创建模板?
? Save this as a preset for future projects? (y/N)

 

保存时指定模板名称:

# 保存命名:
? Save preset as:

依赖构建工具选择:

YARN或者NPM,这里选择NPM

# 依赖构建选择哪种工具, Yarn, NPM
选择NPM, 然后自动下载依赖
? Pick the package manager to use when installing dependencies: (Use arrow keys)
> Use Yarn
Use NPM

构建完成时输出:

# 项目构建完成
Vue CLI v5.0.4
Creating project in G:\frontend-note\Stage6 Vue\demo-first.
⚙️ Installing CLI plugins. This might take a while... > core-js@3.22.3 postinstall G:\frontend-note\Stage6 Vue\demo-first\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}" added 829 packages from 460 contributors in 85.615s
Invoking generators...
Installing additional dependencies... added 17 packages from 15 contributors in 6.856s
Running completion hooks... Generating README.md... Successfully created project demo-first.
Get started with the following commands: $ cd demo-first
$ npm run serve PS G:\frontend-note\Stage6 Vue>

 

创建成功会提示如何运行这个项目模板:

  Successfully created project demo-first.
Get started with the following commands: $ cd demo-first
$ npm run serve

模板目录结构:

Name
----
node_modules - 构建依赖
public
- favor.ico 标签 logo
- index.html 首页
src - 源码目录
- assets文件夹:存放项目中用到的静态资源文件,例如: ess样式表、图片资源
- components文件夹: 程序员封装的、可复用的组件,都要放到components目录下
- main.js是项目的入口文件。整个项目的运行,要先执行main.js
- App.vue是项目的根组件。
.browserslistrc
.gitignore
babel.config.js
jsconfig.json
package-lock.json
package.json
README.md
vue.config.js

 

在工程化的项目中,vue要做的事情很单纯:

通过|main.js|把App.vue渲染到index.html的指定区域中。

 

【Vue2】Vue-Cli使用的更多相关文章

  1. Vue CLI创建Vue2项目

    1.安装Node.js * Node.js中包含了npm工具 安装后查看版本: node -v npm -v 2.设置npm的源为国内源 npm config set registry https:/ ...

  2. 13. Vue CLI脚手架

    一. Vue CLI 介绍 1. 什么是Vue CLI? Vue CLI 是一个基于 Vue.js 进行快速开发的完整系统.Vue CLI 致力于将 Vue 生态中的工具基础标准化.它确保了各种构建工 ...

  3. Vue CLI 是如何实现的 -- 终端命令行工具篇

    Vue CLI 是一个基于 Vue.js 进行快速开发的完整系统,提供了终端命令行工具.零配置脚手架.插件体系.图形化管理界面等.本文暂且只分析项目初始化部分,也就是终端命令行工具的实现. 0. 用法 ...

  4. Vue CLI 5 和 vite 创建 vue3.x 项目以及 Vue CLI 和 vite 的区别

    这几天进入 Vue CLI 官网,发现不能选择 Vue CLI 的版本,也就是说查不到 vue-cli 4 以下版本的文档. 如果此时电脑上安装了 Vue CLI,那么旧版安装的 vue 项目很可能会 ...

  5. vue cli 3.x 项目部署到 github pages

    github pages 是 github 免费为用户提供的服务,写博客,或者部署一些纯静态项目. 最近将 vue cli 3.x 初始化项目部署到 github pages,踩了一些坑,记录如下. ...

  6. @vue/cli 3.0 使用 svg-sprite-loader 加载本地 SVG 文件

    目录 @vue/cli 3.0 使用 svg-sprite-loader 加载本地 SVG 文件 运行 使用 配置 svg-sprite-loader 调用当前环境下的颜色 props @vue/cl ...

  7. vue cli使用融云实现聊天

    公司有个项目要实现一个聊天功能,需求如下图,略显随意 公司最终选择融云这个吊炸天的即时通信,文档详细的一匹,刚开始看文档感觉很详细实现起来也不麻烦,有很多开源的demo可以在线演示和下载 不过我们的项 ...

  8. Vue CLI 3.0脚手架如何在本地配置mock数据

    前后端分离的开发模式已经是目前前端的主流模式,至于为什么会前后端分离的开发我们就不做过多的阐述,既然是前后端分离的模式开发肯定是离不开前端的数据模拟阶段. 我们在开发的过程中,由于后台接口的没有完成或 ...

  9. Vue CLI 3使用:浏览器兼容性

    package.json 文件里的 browserslist 字段 (或一个单独的 .browserslistrc 文件),指定了项目的目标浏览器的范围.这个值会被 @babel/preset-env ...

  10. 基于vue cli 3.0创建前端项目并安装cube-ui

    前提条件: 安装node.js. 国内的开发者最好先配置淘宝镜像. 之后用cnpm来代替npm命令. 项目创建过程: 打开cmd,输入命令进入目标工作空间,以本机项目为例: cd /d d: cd D ...

随机推荐

  1. RabbitMQ 进阶使用之延迟队列 → 订单在30分钟之内未支付则自动取消

    开心一刻 晚上,媳妇和儿子躺在沙发上 儿子疑惑的问道:妈妈,你为什么不去上班 媳妇:妈妈的人生目标是前20年靠父母养,后40年靠你爸爸养,再往后20年就靠你和妹妹养 儿子:我可养不起 媳妇:为什么 儿 ...

  2. uniapp 跳转tabbar页面传递参数

    我们这里采用的是本地缓存的方式进行页面的传参 首先看下官方有关本地缓存的介绍 1.设置本地缓存(-- uni.setStorageSync(KEY,DATA) --) 参数 类型 必填 说明 key ...

  3. swap文件修复

    修复swap文件 vim -r /aaaa.swap

  4. 小程序视图组件 scroll-view

    视图容器组件 3.2.1.swiper 滑块视图容器. https://developers.weixin.qq.com/miniprogram/dev/component/swiper.html 3 ...

  5. CSP-S2023 题解

    CSP-S 2023 题解 密码锁 发现总状态数只有 \(10^5\) 个,枚举 \(O(n)\) 暴力判断即可,复杂度 \(O(10^5 n)\). 或者每一个状态只对应了 \(81\) 个状态,枚 ...

  6. #9134.反转eehniy

    blog 题面 yinhee 去面试 Google 总裁. 面试官给他了一个长度为 \(n\) 的 \(01\) 串. 面试官给他以下两种操作是的这个序列前 \(n-m\) 个数字与后 \(n-m\) ...

  7. 使用 nsenter 排查容器网络问题

    需求 我想进入容器中执行 curl 命令探测某个地址的连通性,但是容器镜像里默认没有 curl 命令.我这里是一个内网环境不太方便使用 yum 或者 apt 安装,怎么办? 这个需求比较典型,这里教大 ...

  8. ssh进阶

    1.ssh客户端工具 查看参数和帮助方法 ==ssh --help== ==man ssh== 常见参数 windows linux macos 提供的ssh命令,会有些区别,查看帮助后使用即可. l ...

  9. 使用python+pytesseract实现图片中文字的识别

    一.安装tesseract 1.下载链接 https://digi.bib.uni-mannheim.de/tesseract/ 2.网盘下载地址 链接:https://pan.baidu.com/s ...

  10. mysql8.0.22在centos7.6下的简单安装

    如果想把mysql安装得好一些,则严重推荐使用压缩包来安装,不推荐使用rpm方式. 一般情况下,现在大部分的服务器都是x86-64,少数是arm架构的. 选择合适的版本,下载即可. 本文中,使用的是 ...