Element UI实现基本的布局,以及引用Echars
ztj100 2024-12-03 06:54 29 浏览 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 效果如下
相关推荐
- 电脑装系统用GHOST好,还是原装版本好?老司机都是这么装的
-
Hello大家好,我是兼容机之家的咖啡。安装Windows系统是原版ISO好还是ghost好呢?针对这个的问题,我们先来科普一下什么是ghost系统,和原版ISO镜像两者之间有哪些优缺点。如果是很了解...
- 苹果 iOS 14.5.1/iPadOS 14.5.1 正式版发布
-
IT之家5月4日消息今日凌晨,苹果发布了iOS14.5.1与iPadOS14.5.1正式版更新。这一更新距iOS14.5正式版发布过去了一周时间。IT之家了解到,苹果表示,...
- iOS 13.1.3 正式版发布 包含错误修复和改进
-
苹果今天发布了iOS13.1.3和iPadOS13.1.3,这是iOS13发布之后第四个升级补丁。iOS13.1.2两周前发布。iOS13.1.3主要包括针对iPad和...
- 还不理解 Error 和 Exception 吗,看这篇就够了
-
在Java中的基本理念是结构不佳的代码不能运行,发现错误的理想时期是在编译期间,因为你不用运行程序,只是凭借着对Java基本理念的理解就能发现问题。但是编译期并不能找出所有的问题,有一些N...
- Linux 开发人员发现了导致 MacBook“无法启动”的 macOS 错误
-
“多个严重”错误影响配备ProMotion显示屏的MacBookPro。...
- 启动系统时无法正常启动提示\windows\system32\winload.efi
-
启动系统时无法正常启动提示\windows\system32\winload.efi。该怎么解决? 最近有用户遇到了开机遇到的问题,是Windows未能启动。原因可能是最近更改了硬件或软件。虽然提...
- 离线部署之两种构建Ragflow镜像的方式,dify同理
-
在实际项目交付过程中,经常遇到要离线部署的问题,生产服务器无法连接外网,这时就需要先构建好ragflow镜像,然后再拷到U盘或刻盘,下面介绍两种构建ragflow镜像的方式。性能测试(网络情况好的情况...
- Go语言 error 类型详解(go语言 异常)
-
Go语言的error类型是用于处理程序运行中错误情况的核心机制。它通过显式的返回值(而非异常抛出)来管理错误,强调代码的可控性和清晰性。以下是详细说明及示例:一、error类型的基本概念内置接口...
- Mac上“闪烁的问号”错误提示如何修复?
-
现在Mac电脑的用户越来越多,Mac电脑在使用过程中也会出现系统故障。当苹果电脑无法找到系统软件时,Mac会给出一个“闪烁的问号”的标志。很多用户受到过闪烁问号这一常见的错误提示的影响,如何解决这个问...
- python散装笔记——177 sys 模块(python sys模块详解)
-
sys模块提供了访问程序运行时环境的函数和值,例如命令行参数...
- 30天自制操作系统:第一天(30天自制操作系统电子书)
-
因为咱们的目的是为了研究操作系统的组成,所以直接从系统启动的第二阶段的主引导记录开始。前提是将编译工具放在该文件目录的同级目录下,该工具为日本人川合秀实自制的编译程序,优化过的nasm编译工具。...
- 五大原因建议您现在不要升级iOS 13或iPadOS
-
今天苹果放出了iPadOS和iOS13的公测版本,任何对新版功能感兴趣的用户都可以下载安装参与测试。除非你想要率先体验Dark模式,以及使用AppleID来登陆Facebook等服务,那么外媒CN...
- Python安装包总报错?这篇解决指南让你告别pip烦恼!
-
在Python开发中,...
- 苹果提供了在M1 Mac上修复macOS重装错误的方案
-
#AppleM1芯片#在苹果新的M1Mac推出后不久,我们看到有报道称,在这些机器上恢复和重新安装macOS,可能会导致安装错误,使你的Mac无法使用。具体来说,错误信息如下:"An...
- 黑苹果卡代码篇三:常见卡代码问题,满满的干货
-
前言...
你 发表评论:
欢迎- 一周热门
- 最近发表
-
- 电脑装系统用GHOST好,还是原装版本好?老司机都是这么装的
- 苹果 iOS 14.5.1/iPadOS 14.5.1 正式版发布
- iOS 13.1.3 正式版发布 包含错误修复和改进
- 还不理解 Error 和 Exception 吗,看这篇就够了
- Linux 开发人员发现了导致 MacBook“无法启动”的 macOS 错误
- 启动系统时无法正常启动提示\windows\system32\winload.efi
- 离线部署之两种构建Ragflow镜像的方式,dify同理
- Go语言 error 类型详解(go语言 异常)
- Mac上“闪烁的问号”错误提示如何修复?
- python散装笔记——177 sys 模块(python sys模块详解)
- 标签列表
-
- 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)
- node卸载 (33)
- npm 源 (35)
- vue3 deep (35)
- win10 ssh (35)
- exceptionininitializererror (33)
- 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)