1.3 vue ui框架-element-ui框架

1 前言

ElementUI是一套基于VUE2.0的桌面端组件库,ElementUI提供了丰富的组件帮助开发人员快速构建功能强大、风格统一的页面。

ElementUI官网 https://element.eleme.io

2 安装

运行命令

复制代码
cnpm i element-ui -S

-S表示只在该项目下安装,不是全局安装

注意:要跳到项目所在目录运行

会在node_modules文件夹下生成element-ui子目录

3 应用

1.1 创建第一个vue项目-CSDN博客生成的项目。

3.1 在src/main.js中引入element组件,修改后代码如下:

复制代码
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

/*引入element组件*/
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
 
Vue.config.productionTip = false
 
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

3.2 修改src/components/HelloWorld.vue代码如下

复制代码
<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <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>
  </div>
</template>
 
<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      msg: "使用element-ui测试",
    };
  },
};
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

3.3 运行效果

在cmd运行命令npm run dev 然后访问http://localhost:8080,效果如下:

相关推荐
武昌库里写JAVA1 小时前
C语言 #pragma once - C语言零基础入门教程
vue.js·spring boot·sql·layui·课程设计
iCoding911 小时前
前端分页 vs 后端分页:技术选型
前端·后端·系统架构
mingtianyihou331 小时前
使用 Service Worker 限制请求并发数
前端
张可爱1 小时前
20251017-Vue2八股文整理(上篇)
前端
FanetheDivine1 小时前
ts中如何描述一个复杂函数的类型
前端·typescript
lightgis1 小时前
chrome中的axure插件提示无法不受支持
前端·chrome
速易达网络2 小时前
Vue3 原生移动应用开发来了
前端·javascript·css
GISer_Jing2 小时前
LLM对话框项目技术栈&重难点总结
前端·ai·node.js
我爱学习_zwj2 小时前
【鸿蒙进阶-7】鸿蒙与web混合开发
前端·华为·harmonyos
小谭鸡米花2 小时前
高德地图电子围栏/地图选区/地图打点
前端·javascript·vue.js