Vue 引入 Element-UI 组件库

Element-UI 官网地址:https://element.eleme.cn/#/zh-CN

完整引入:会将全部组件打包到项目中,导致项目过大,首次加载时间过长。

下载 Element-UI

一、打开项目,安装 Element-UI 组件库。

使用命令:

npm i element-ui -S

完整引入:

一、在 main.js 文件中,引入组件库和组件样式。

javascript 复制代码
import Vue from 'vue'
import App from './App.vue'
import router from './router'

// 1.引入 Element-UI 组件库
import ElementUI from 'element-ui';
// 2.引入 Element-UI 组件样式
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false

// 3.使用 Element-UI 组件库
Vue.use(ElementUI);

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

二、在官网中找到需要的组件,复制对应的代码。

三、创建 Home.vue 页面,将代码粘贴到页面中。

html 复制代码
<template>
    <el-row>
        <el-button>默认按钮</el-button>
        <el-button type="primary">主要按钮</el-button>
        <el-button type="success">成功按钮</el-button>
        <el-button type="info">信息按钮</el-button>
        <el-button type="warning">警告按钮</el-button>
        <el-button type="danger">危险按钮</el-button>
    </el-row>
</template>

<script>
export default {
    name: "Home",
}
</script>

四、最终效果

原创作者:吴小糖

创作时间:2023.8.14

相关推荐
小鸡吃米…24 分钟前
Python - 类属性
java·前端·python
前端不太难34 分钟前
Navigation State 驱动的页面调试方法论
开发语言·前端·react.js
用户47949283569151 小时前
你每天都在用的 JSON.stringify ,V8 给它开了“加速通道”
前端·chrome·后端
JIngJaneIL1 小时前
基于java+ vue办公管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
静待雨落1 小时前
Electron无边框窗口如何拖拽以及最大化和还原窗口
前端·electron
沐泽__2 小时前
iframe内嵌页面双向通信
前端·javascript·chrome
小北方城市网2 小时前
第4 课:Vue 3 路由与状态管理实战 —— 从单页面到多页面应用
前端·javascript·vue.js
ohyeah2 小时前
用 Vue3 + Coze API 打造冰球运动员 AI 生成器:从图片上传到风格化输出
前端·vue.js·coze
Dragon Wu2 小时前
TailWindCss 核心功能总结
前端·css·前端框架·postcss
SHolmes18542 小时前
给定某日的上班时间段,计算当日的工作时间总时长(Python)
开发语言·前端·python