Element UI实现基本的布局,以及引用Echars
ztj100 2024-12-03 06:54 85 浏览 0 评论
导入Element ui插件
npm i element-ui -S
配置Element UI
在src文件夹下的main.js的配置如下
代码为:
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.config.productionTip = false
Vue.use(ElementUI)
然后在组件中使用Element UI
具体的使用方法大家到Element UI官网中进行选择,官网地址为
https://element.eleme.cn/#/zh-CN
大家根据需要选择组件
这是我根据B站的视频仿出来的一个布局
代码如下:
<template>
<div>
<el-container>
<el-header>车载物联网无线通信滑移门运行数据回传系统</el-header>
<el-main>
<div id="car-speed" class="car-speed"></div>
<div class="car-position"></div>
<div class="show-other"></div>
<div class="car-count"></div>
<div class="car-status"></div>
</el-main>
<el-footer>Footer</el-footer>
</el-container>
</div>
</template>
<script>
export default {
mounted() {
this.setChar()
},
name: 'Data',
components: {
//组件
},
methods: {
setChar() {
let myChart = this.$echarts.init(document.getElementById('car-speed'), 'white')
var option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line',
},
],
}
// 绘制图表
myChart.setOption(option);
},
},
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped >
.el-header,
.el-footer {
height: 240px;
background-color: #b3c0d1;
color: #333;
text-align: center;
line-height: 60px;
}
.el-main {
height: 600px;
background-color: #e9eef3;
color: #333;
text-align: center;
line-height: 160px;
}
.car-speed {
margin-left: 5px;
width: 500px;
height: 300px;
background-color: black;
border-radius: 15px 15px 0 0;
}
.car-position {
position: absolute;
margin-top: 20px;
margin-left: 5px;
width: 500px;
height: 250px;
background-color: burlywood;
border-radius: 15px 15px 15px 15px;
}
.car-count {
position: absolute;
margin-top: 20px;
margin-left: 1000px;
width: 500px;
height: 250px;
background-color: black;
border-radius: 15px 15px 15px 15px;
}
.car-status {
position: absolute;
margin-top: -300px;
margin-left: 1000px;
width: 500px;
height: 300px;
background-color: #b3c0d1;
border-radius: 15px 15px 15px 15px;
}
.show-other {
position: absolute;
margin-top: -300px;
margin-left: 510px;
width: 480px;
height: 570px;
background-color: #b3c0d1;
border-radius: 15px 15px 15px 15px;
}
</style>
需要注意的就是它的CSS了,我写的这个CSS比较拉跨,建议大家自行编写。(CSS永远的痛)
下面是我使用Element UI编写的一个登录界面,看起来好丑(哈哈哈哈)。不过功能还是不错的。
具体实现代码如下:
<template>
<div class="login-container">
<div class="login-body">
欢迎来到车载物联网系统
<!-- 登录界面头部 -->
<div class="login-header">用户登录</div>
<!-- 登录界面表单 -->
<!-- ref:得到表单实例对象 :model :相当于v-bind -->
<el-form ref="loginFormRef" :model="loginForm" :rules="rules" class="login-form">
<el-form-item prop="useruame" label="用户名">
<el-input v-model="loginForm.useruame" placeholder="请输入用户名"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input
type="password"
v-model="loginForm.password"
autocomplete="off"
placeholder="请输入密码"
show-password
></el-input>
</el-form-item>
<!-- 登录界面按钮 -->
<el-form-item class="btn">
<el-button type="primary" @click="onLogin('loginFormRef')">登录</el-button>
<el-button type="info" @click="resetLoginForm">重置</el-button>
</el-form-item>
</el-form>
<!-- 登录界面其他选项 -->
<div class="other-option">
<span @click="onRegister">注册账户</span>
<span style="margin: 0 30px">|</span>
<span>找回密码</span>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
//登录表单的数据绑定对象,记得加上:
loginForm: {
input: '',
useruame: '',
password: '',
},
//登录表单的验证规则对象,规则名字要和loginForm的一样
rules: {
// 用户名规则
useruame: [
{ required: true, message: '请输入用户名', trigger: 'blur' },
{ min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' },
],
// 密码规则
password: [
{ required: true, message: '请输入密码', trigger: 'blur' },
{ min: 8, max: 16, message: '长度在 8 到 16 个字符', trigger: 'blur' },
],
},
}
},
methods: {
onLogin(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
const result = this.$http.post('login', this.loginForm)
console.log(result)
var useruame1 = localStorage.userName
var password1 = localStorage.passWord
console.log('获得用户名' + useruame1)
console.log('获得密码' + password1)
if (useruame1 === this.loginForm.useruame && password1 === this.loginForm.password) {
this.$alert('', '登录成功', {
showClose:true,
showConfirmButton:true,
callback: (action) => {
this.$message({
type: 'info',
message: `action: ${action}`,
})
},
})
this.$router.replace('/Data')
} else {
this.$alert('用户名或密码错误!', '登录失败', {
confirmButtonText: '确定',
callback: (action) => {
this.$message({
type: 'info',
message: `action: ${action}`,
})
},
})
}
} else {
console.log('error submit!!')
return false
}
})
console.log(this.loginForm.useruame)
},
// 清空表单值
resetLoginForm() {
this.$refs.loginFormRef.resetFields()
},
//跳转至注册页面
onRegister() {
console.log('点击注册用户')
this.$router.replace('/Register') //默认全局配置$router属性
},
},
}
</script>
// scoped只在当前组件生效
<style lang="scss" scoped>
.login-container {
height: 500px;
width: 500px;
background-color: #fff5ee;
background-image: url('../assets/login.png');
position: absolute;
top: 50%;
left: 50%;
// 设置div的中心点在我们想要的位置
transform: translate(-50%, -50%);
.login-header {
background-color: #b3c0d1;
color: #333;
text-align: center;
line-height: 60px;
}
.login-form {
color: #3d7ef9;
width: 300px;
height: 300px;
border-radius: 15px 15px 0 0;
background-color: #fff;
margin-top: 20px;
margin-left: 20%;
padding: 0px 10px; //输入框与登录框两侧的距离
}
}
.btn {
display: flex; //弹性布局
justify-content: center; //置中
}
.other-option {
display: flex; //弹性布局
justify-content: center; //置中
background-color: #fff;
width: 320px;
margin-left: 20%;
margin-bottom: 30x;
}
</style>
如何导入并使用Echars插件
安装与配置基本与Element UI的一样,Echars的官网地址为
https://echarts.apache.org/zh/index.html
安装插件
npm install echarts --save
配置插件(src文件下的main.js)
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
使用插件
1 定义界面框的大小
2 编写具体的图形参数
3 效果如下
相关推荐
- sharding-jdbc实现`分库分表`与`读写分离`
-
一、前言本文将基于以下环境整合...
- 三分钟了解mysql中主键、外键、非空、唯一、默认约束是什么
-
在数据库中,数据表是数据库中最重要、最基本的操作对象,是数据存储的基本单位。数据表被定义为列的集合,数据在表中是按照行和列的格式来存储的。每一行代表一条唯一的记录,每一列代表记录中的一个域。...
- MySQL8行级锁_mysql如何加行级锁
-
MySQL8行级锁版本:8.0.34基本概念...
- mysql使用小技巧_mysql使用入门
-
1、MySQL中有许多很实用的函数,好好利用它们可以省去很多时间:group_concat()将取到的值用逗号连接,可以这么用:selectgroup_concat(distinctid)fr...
- MySQL/MariaDB中如何支持全部的Unicode?
-
永远不要在MySQL中使用utf8,并且始终使用utf8mb4。utf8mb4介绍MySQL/MariaDB中,utf8字符集并不是对Unicode的真正实现,即不是真正的UTF-8编码,因...
- 聊聊 MySQL Server 可执行注释,你懂了吗?
-
前言MySQLServer当前支持如下3种注释风格:...
- MySQL系列-源码编译安装(v5.7.34)
-
一、系统环境要求...
- MySQL的锁就锁住我啦!与腾讯大佬的技术交谈,是我小看它了
-
对酒当歌,人生几何!朝朝暮暮,唯有己脱。苦苦寻觅找工作之间,殊不知今日之事乃我心之痛,难道是我不配拥有工作嘛。自面试后他所谓的等待都过去一段时日,可惜在下京东上的小金库都要见低啦。每每想到不由心中一...
- MySQL字符问题_mysql中字符串的位置
-
中文写入乱码问题:我输入的中文编码是urf8的,建的库是urf8的,但是插入mysql总是乱码,一堆"???????????????????????"我用的是ibatis,终于找到原因了,我是这么解决...
- 深圳尚学堂:mysql基本sql语句大全(三)
-
数据开发-经典1.按姓氏笔画排序:Select*FromTableNameOrderByCustomerNameCollateChinese_PRC_Stroke_ci_as//从少...
- MySQL进行行级锁的?一会next-key锁,一会间隙锁,一会记录锁?
-
大家好,是不是很多人都对MySQL加行级锁的规则搞的迷迷糊糊,一会是next-key锁,一会是间隙锁,一会又是记录锁。坦白说,确实还挺复杂的,但是好在我找点了点规律,也知道如何如何用命令分析加...
- 一文讲清怎么利用Python Django实现Excel数据表的导入导出功能
-
摘要:Python作为一门简单易学且功能强大的编程语言,广受程序员、数据分析师和AI工程师的青睐。本文系统讲解了如何使用Python的Django框架结合openpyxl库实现Excel...
- 用DataX实现两个MySQL实例间的数据同步
-
DataXDataX使用Java实现。如果可以实现数据库实例之间准实时的...
- MySQL数据库知识_mysql数据库基础知识
-
MySQL是一种关系型数据库管理系统;那废话不多说,直接上自己以前学习整理文档:查看数据库命令:(1).查看存储过程状态:showprocedurestatus;(2).显示系统变量:show...
- 如何为MySQL中的JSON字段设置索引
-
背景MySQL在2015年中发布的5.7.8版本中首次引入了JSON数据类型。自此,它成了一种逃离严格列定义的方式,可以存储各种形状和大小的JSON文档,例如审计日志、配置信息、第三方数据包、用户自定...
你 发表评论:
欢迎- 一周热门
-
-
MySQL中这14个小玩意,让人眼前一亮!
-
旗舰机新标杆 OPPO Find X2系列正式发布 售价5499元起
-
【VueTorrent】一款吊炸天的qBittorrent主题,人人都可用
-
面试官:使用int类型做加减操作,是线程安全吗
-
C++编程知识:ToString()字符串转换你用正确了吗?
-
【Spring Boot】WebSocket 的 6 种集成方式
-
PyTorch 深度学习实战(26):多目标强化学习Multi-Objective RL
-
pytorch中的 scatter_()函数使用和详解
-
与 Java 17 相比,Java 21 究竟有多快?
-
基于TensorRT_LLM的大模型推理加速与OpenAI兼容服务优化
-
- 最近发表
- 标签列表
-
- idea eval reset (50)
- vue dispatch (70)
- update canceled (42)
- order by asc (53)
- spring gateway (67)
- 简单代码编程 贪吃蛇 (40)
- transforms.resize (33)
- redisson trylock (35)
- 卸载node (35)
- np.reshape (33)
- torch.arange (34)
- npm 源 (35)
- vue3 deep (35)
- win10 ssh (35)
- vue foreach (34)
- idea设置编码为utf8 (35)
- vue 数组添加元素 (34)
- std find (34)
- tablefield注解用途 (35)
- python str转json (34)
- java websocket客户端 (34)
- tensor.view (34)
- java jackson (34)
- vmware17pro最新密钥 (34)
- mysql单表最大数据量 (35)