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,效果如下:

相关推荐
不想有bug的小菜鸟4 分钟前
vue3使用iframe全屏展示pdf效果
前端·pdf
m0_748238634 分钟前
Spring Boot项目接收前端参数的11种方式
前端·spring boot·后端
u0100559605 分钟前
前端代理,解决跨域问题讲解
前端
quitv10 分钟前
react脚手架配置别名
前端·javascript·react.js
m0_5287238119 分钟前
前端如何进行性能优化
前端·性能优化
化作繁星21 分钟前
在 Vue 3 中,如何缓存和复用动态组件
前端·vue.js·缓存
一粒沙-40 分钟前
iOS 将GIF图分享至微信
前端·ios
graywen44 分钟前
从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
前端
一只小姜丝3321 小时前
解决各大浏览器中http地址无权限调用麦克风摄像头问题
网络·vue.js·网络协议·http
Gazer_S2 小时前
【现代前端框架中本地图片资源的处理方案】
前端·javascript·chrome·缓存·前端框架