【Vue2】Vue-Cli使用
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使用的更多相关文章
- Vue CLI创建Vue2项目
1.安装Node.js * Node.js中包含了npm工具 安装后查看版本: node -v npm -v 2.设置npm的源为国内源 npm config set registry https:/ ...
- 13. Vue CLI脚手架
一. Vue CLI 介绍 1. 什么是Vue CLI? Vue CLI 是一个基于 Vue.js 进行快速开发的完整系统.Vue CLI 致力于将 Vue 生态中的工具基础标准化.它确保了各种构建工 ...
- Vue CLI 是如何实现的 -- 终端命令行工具篇
Vue CLI 是一个基于 Vue.js 进行快速开发的完整系统,提供了终端命令行工具.零配置脚手架.插件体系.图形化管理界面等.本文暂且只分析项目初始化部分,也就是终端命令行工具的实现. 0. 用法 ...
- Vue CLI 5 和 vite 创建 vue3.x 项目以及 Vue CLI 和 vite 的区别
这几天进入 Vue CLI 官网,发现不能选择 Vue CLI 的版本,也就是说查不到 vue-cli 4 以下版本的文档. 如果此时电脑上安装了 Vue CLI,那么旧版安装的 vue 项目很可能会 ...
- vue cli 3.x 项目部署到 github pages
github pages 是 github 免费为用户提供的服务,写博客,或者部署一些纯静态项目. 最近将 vue cli 3.x 初始化项目部署到 github pages,踩了一些坑,记录如下. ...
- @vue/cli 3.0 使用 svg-sprite-loader 加载本地 SVG 文件
目录 @vue/cli 3.0 使用 svg-sprite-loader 加载本地 SVG 文件 运行 使用 配置 svg-sprite-loader 调用当前环境下的颜色 props @vue/cl ...
- vue cli使用融云实现聊天
公司有个项目要实现一个聊天功能,需求如下图,略显随意 公司最终选择融云这个吊炸天的即时通信,文档详细的一匹,刚开始看文档感觉很详细实现起来也不麻烦,有很多开源的demo可以在线演示和下载 不过我们的项 ...
- Vue CLI 3.0脚手架如何在本地配置mock数据
前后端分离的开发模式已经是目前前端的主流模式,至于为什么会前后端分离的开发我们就不做过多的阐述,既然是前后端分离的模式开发肯定是离不开前端的数据模拟阶段. 我们在开发的过程中,由于后台接口的没有完成或 ...
- Vue CLI 3使用:浏览器兼容性
package.json 文件里的 browserslist 字段 (或一个单独的 .browserslistrc 文件),指定了项目的目标浏览器的范围.这个值会被 @babel/preset-env ...
- 基于vue cli 3.0创建前端项目并安装cube-ui
前提条件: 安装node.js. 国内的开发者最好先配置淘宝镜像. 之后用cnpm来代替npm命令. 项目创建过程: 打开cmd,输入命令进入目标工作空间,以本机项目为例: cd /d d: cd D ...
随机推荐
- 使用Logstash同步Mysql到Easysearch
从 MySQL 同步数据到 ES 有多种方案,这次我们使用 ELK 技术栈中的 Logstash 来将数据从 MySQL 同步到 Easysearch . 方案前提 MySQL 表记录必须有主键,比如 ...
- DoNet Core的启动过程-WebApplicationBuilder
1.前言 在NET6开始做ASP.NETCore的开发,我们首先要看的是启动过程,而WebApplication和WebApplicationBuilder 类是启动过程好不开的类,WebApplic ...
- js沙雕排序之睡眠排序&随机排序
1.睡眠排序,只要睡的时间多少就可以排序出来不要在乎时间多少 var arr=[4,77,741,41,142,52,244]; var sleepSort=function(arr,callback ...
- Navicat Premium v16.0.6 绿色破解版
这里版本:Navicat Premium v16.0.6.0 ,这个是绿色版,不需要安装,启动Navicat.exe即可用 破解工具:NavicatKeygenPatch(其它版本也能破解) 1.下载 ...
- c# 基础小知识备忘录
记性不大好,记下来 First 和 FirstOrDefault First方法:返回List集合序列中的第一个符合条件的元素,如果没有查找到,则抛出运行时异常. FirstOrDefault方法: ...
- Hive怎么调整优化Tez引擎的查询?在Tez上优化Hive查询的指南
目录 在Tez上优化Hive查询的指南 调优指南 理解Tez中的并行化 理解mapper数量 理解reducer数量 并发 案例1:未指定队列名称 案例2:指定队列名称 并发的指南/建议 容器复用和预 ...
- metal invalid pixel format xx
这个时候要考虑CAMetalLayer.pixelFormat是否设置设置正确,虽然MTLPixelFormat有很多枚举值,但是CAMetalLayer支持的也就只有五个: MTLPixelForm ...
- spring与设计模式之四适配器模式
一.定义 适配器模式-或者称为转接口模式,变压器模式.通过适配,可以让原来提供特定功能的对象完成另外一个标准的功能. 所以,所谓的适配应该可以这样称呼:让某些类/接口适配/转换某个标准/功能. 适配器 ...
- VScode连接服务器不用每次都输入密码
VScode连接服务器不用每次都输入密码. 用git或xcode的ssh keygen生成一组不带密码的 rsa2048 的公钥id_rsa_nopasswd.pub和私钥id_rsa_nopassw ...
- CodeServer 不能粘贴
CodeServer 在没有SSL证书时, 由一浏览器的限制, 默认是不能粘贴的. 在局域网中, 如果不考虑安全性的话, 可以考虑直接把加密关掉, 就能复制粘贴了. 配置文件如下: cert: Tru ...