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

结果如图所示

相关推荐
Lanwarf-前端开发8 分钟前
Vue3 + Canvas/WebGL 雷达扫描可视化实战:PPI、RHI、VOL、SVOL 四种模式原理与实现
前端·javascript·vue.js·webgl
FRing031 小时前
vue3干货总结2(vue3生命周期、父子通信、模版引用、provide和inject)
开发语言·前端·vue.js·vue3
锋行天下3 小时前
langgraph 全栈项目(三)
前端·人工智能·后端
YIAN3 小时前
从 LangChain 到 DeepAgents:手把手拆解 createAgent、Middleware 与复杂 Agent
javascript·langchain·deepseek
锋行天下3 小时前
langgraph 全栈项目(二)
前端·人工智能·后端
冬夜Zis4 小时前
顺着作用域链和 outer 指针,一次性看懂闭包底层逻辑
javascript
Ceelog4 小时前
Mac 上怎么找出并安全清理旧的 node_modules?(实测 304 个占 66.3 GB)
javascript
锋行天下4 小时前
langgraph全栈项目(一)
前端·人工智能·后端
叼烟扛炮5 小时前
[LangChain] 学习笔记(15):为什么你的重试没用——429、抖动、fallback 与熔断
java·服务器·前端