Element-UI安装与使用

ElementUI安装

vue-cli-plugin-element
npm和CDN

npm安装

使用npm安装element-ui

npm i element-ui -S

报了如下错误:

Invalid response body while trying to fetch https://registry.npmjs.org/async-validator: Integrity verification 

尝试清除缓存

npm cache clear --force
# 或者
npm cache verify

然后再安装就成功了。
搜资料的时候也有遇到Response timeout报错的解决办法,先收藏起来。

babel-plugin-component插件

ElementUI官方安装教程
这里有个问题:
官方提供了按需引入Element的方法,其中提到修改.babelrc,但是我的项目里没有.babelrc文件,只有babel.config.js。(后来才发现这是因为我使用的vue3 ,然鹅支持vue3的是elementUI升级版elementPLUS,所以安装过程才不一样。)
关于这个问题解决方案看这里
babel官方文档有提到:
babel.config.js是项目范围的配置文件,
.babelrc是文件相关配置,他允许为包的子部分进行相关配置。

npm

然后回头研究了下npm报的错

[email protected] requires a peer of vue@^2.5.17 but none is installed. You must install peer dependencies yourself

搞了半天原来element-ui只适用于vue2,而我的项目用的vue3,换成element-plus重来

npm install element-plus --save
npm uninstall element-ui
安装postcss

安装完element plus还有这个报错需要处理

[email protected] requires a peer of postcss@^8.1.0 but none is installed. You must instal
l peer dependencies yourself.

postcss-modules-local-by-default插件需要安装postcss,

npm install postcss@^8.1.0

postcsss是什么?搜了一下这篇15年的介绍postcss的文章,当然过去这么多年,postcss肯定有很大的发展。这是关于postcss8插件迁移的文章。然后又接触到了CSS Modules的概念

查看已安装的某插件版本

想要查看某插件的版本可以使用一下命令

npm ls <插件名称>
# 或者ls换成ls/la/ll
# la/ll除了版本号还会输出插件git和官网地址信息
相关资源链接

core-js

npm中-s 和 -D的区别

你可能感兴趣的:(开发记录)