Element-ui的使用教程 基于HBuilder X

文章目录

1.Element-ui简介

Element,一套为开发者、设计师和产品经理准备的基于 Vue 的桌面端组件库

element-ui官网地址

https://element-plus.org/zh-CN/guide/installation.html

2.使用HBuilderX 创建一个基于Vue3的项目 (由于是使用的基于Vue3的Element-ui)

HBuilderX 安装 自行百度

3.安装element-ui

在HBuilderX 打开控制台界面 输入如下命令 执行安装

bat 复制代码
npm install element-plus --save

4.在项目里完全引用element-ui

修改main.js文件添加如下代码

javascript 复制代码
// main.ts
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'

const app = createApp(App)

app.use(ElementPlus)
app.mount('#app')

5.引用组件

这里以button 按钮为例

标签是

html 复制代码
    <div class="mb-4">
      <el-button>Default</el-button>
      <el-button type="primary">Primary</el-button>
      <el-button type="success">Success</el-button>
      <el-button type="info">Info</el-button>
      <el-button type="warning">Warning</el-button>
      <el-button type="danger">Danger</el-button>
    </div>

修改App.vue文件 添加一组按钮到页面上

html 复制代码
<template>
  <img alt="Vue logo" src="./assets/logo.png" />
  <HelloWorld msg="Hello Vue 3 + Vite" />
  
    <div class="mb-4">
      <el-button>Default</el-button>
      <el-button type="primary">Primary</el-button>
      <el-button type="success">Success</el-button>
      <el-button type="info">Info</el-button>
      <el-button type="warning">Warning</el-button>
      <el-button type="danger">Danger</el-button>
    </div>
</template>

6.运行项目

bat 复制代码
npm  run dev

结果如图所示

相关推荐
计算机毕设VX:Fegn0895几秒前
计算机毕业设计|基于springboot + vue二手家电管理系统(源码+数据库+文档)
vue.js·spring boot·后端·课程设计
持续升级打怪中18 分钟前
Vue3 中虚拟滚动与分页加载的实现原理与实践
前端·性能优化
GIS之路22 分钟前
GDAL 实现矢量合并
前端
hxjhnct24 分钟前
React useContext的缺陷
前端·react.js·前端框架
冰暮流星32 分钟前
javascript逻辑运算符
开发语言·javascript·ecmascript
前端 贾公子1 小时前
从入门到实践:前端 Monorepo 工程化实战(4)
前端
菩提小狗1 小时前
Sqlmap双击运行脚本,双击直接打开。
前端·笔记·安全·web安全
前端工作日常1 小时前
我学习到的AG-UI的概念
前端
韩师傅1 小时前
前端开发消亡史:AI也无法掩盖没有设计创造力的真相
前端·人工智能·后端
XiaoYu20021 小时前
第12章 支付宝SDK
前端