一站式装修公司有哪些,阿里邮箱登录,起飞页做网站步骤,推广方案万能模板什么是 Element 在现代前端开发中#xff0c;组件化的思想日益盛行#xff0c;Element组件库作为一款流行的UI组件库#xff0c;特别适用于基于Vue.js的项目#xff0c;它为开发者提供了丰富的组件和良好的开发体验。 想要使用Element的组件库#xff0c;我们需要完成下面…什么是 Element 在现代前端开发中组件化的思想日益盛行Element组件库作为一款流行的UI组件库特别适用于基于Vue.js的项目它为开发者提供了丰富的组件和良好的开发体验。 想要使用Element的组件库我们需要完成下面三步…… 安装Element组件库 Element 组件库有多个版本主要对应不同的 Vue 版本。Element UI通常称为 Element是基于 Vue 2.x 开发的而 Element Plus 则是为 Vue 3.x 设计的。这意味着如果您使用的是 Vue 3则需要选择 Element Plus而非传统的 Element UI。 根据自己安装的vue版本安装对应的组件库……我们下载的Element组件库会自动存放到我们Vue项目的 node_modules目录下 npm install element-plus 在项目中引入 Element Plus 很多人会觉得我也不会引入啊不知道命令啊没关系我也不知道那么多命令谁记得住我们直接去官网查看参考手册复制命令就行……
一个 Vue 3 UI 框架 | Element Plus (element-plus.org)这里有很多精美的图标按钮这是vue3版本呢对应的 Element plus 组件库
如果你是 2版本则需要去这个Element - 网站快速成型工具找自己需要的组件代码
打开main.js 文件复制导入包的命令
注意这里图片展示 的是2 版本的对应的引入方法 由于我的是vue3版本所以我下载的是与之对应的Element plus 版本所以下面的引入方法稍有差异如果是2版本的话可以根据官方文档操作 定义Element Plus 组件文件
首先我们需要自己定义一个.vue 的文件来存放我们需要的组件样例我们以plus中的按钮为例…… 复制它的按钮代码存放在我们定义的ElementView.vue 文件中如下 在这个ElementView.vue 文件中我们需要定义三对标签 template /template 用来存放html 结构标签 script/script 存放js代码 stylestyle存放css代码 templatediv classmb-4el-buttonDefault/el-buttonel-button typeprimaryPrimary/el-buttonel-button typesuccessSuccess/el-buttonel-button typeinfoInfo/el-buttonel-button typewarningWarning/el-buttonel-button typedangerDanger/el-button/divdiv classmb-4el-button plainPlain/el-buttonel-button typeprimary plainPrimary/el-buttonel-button typesuccess plainSuccess/el-buttonel-button typeinfo plainInfo/el-buttonel-button typewarning plainWarning/el-buttonel-button typedanger plainDanger/el-button/divdiv classmb-4el-button roundRound/el-buttonel-button typeprimary roundPrimary/el-buttonel-button typesuccess roundSuccess/el-buttonel-button typeinfo roundInfo/el-buttonel-button typewarning roundWarning/el-buttonel-button typedanger roundDanger/el-button/divdivel-button :iconSearch circle /el-button typeprimary :iconEdit circle /el-button typesuccess :iconCheck circle /el-button typeinfo :iconMessage circle /el-button typewarning :iconStar circle /el-button typedanger :iconDelete circle //div
/templatescript langts setup
import {Check,Delete,Edit,Message,Search,Star,
} from element-plus/icons-vue;
/scriptstyle
/* 这里可以添加样式 */
/style修改App.vue 我们需要在App.vue 文件中引入 Element.vue 来进行展示页面清除原有的所有标签给App.vue 也保留这三个标签
templatedivelement-view/element-view/div
/templatescript setup langts
import ElementView from ./views/ElementView.vue;
/scriptstyle/style 总结 Element组件库作为一款优秀的UI库不仅丰富了Vue开发者的组件选择它的易用性和性能优势使得在开发过程中得心应手。无论是前端新手还是经验丰富的开发者都能从中受益。