vue3 数据大屏项目开发中,会遇到各种各样的头部,今天整理的是数据可视化大标题头部组件。
如果您需要设计属于自己的数据可视化大屏或开发数据可视化大屏 请联系我们微信:17331886870
效果截图
帧动画效果
通过ae实现从两侧到中间的扫光动画,使用帧动画生成。帧动画虽然增加了效果同时也增加了文件大小。
帧动画文件大小
帧动画图片文件数量74
帧动画图片文件总大小 3.6M
组件内容
背景加中间为标题
加帧动画效果实例
头部大小
1920 * 77
部分代码
/**
* @Author: 858834013@qq.com
* @Name: pageTop
* @Date: 2023年06月17日22:03:03
* @Desc:
*/
<template>
<div class="pageTop wow fadeInDown">
<sequence fileName="topbg/topbg_" fileLength="74" IntervalTime="50"></sequence>
<div class="left">
</div>
<div class="title">
<span>{{ title }}</span>
</div>
<div class="right">
</div>
</div>
</template>
<script>
import dayjs from 'dayjs'
import sequence from "./sequence.vue";
export default {
name: "pageTop",
components: {sequence},
data() {
return {
date: dayjs().format("YYYY-MM-DD"),
time: dayjs().format("HH:mm:ss"),
}
},
props: {
title: {
type: String,
default() {
return '数据可视化大标题';
}
}
},
computed: {
week() {
var datas = dayjs().day()
var week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
return week[datas]
}
},
mounted() {
var that = this;
setInterval(function () {
that.time = dayjs().format("HH:mm:ss");
}, 1000);
},
methods: {}
}
</script>
<style lang="scss" scoped>
.pageTop {
width: 100%;
height: 77px;
display: flex;
position: relative;
justify-content: center;
align-items: flex-start;
flex-wrap: nowrap;
flex-direction: row;
align-content: flex-start;
.left {
width: calc(30% - 100px);
margin-left: 100px;
position: relative;
height: 100%;
display: flex;
justify-content: flex-start;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
align-content: flex-start;
}
.right {
width: calc(30% - 120px);
margin-right: 120px;
position: relative;
height: 100%;
display: flex;
justify-content: flex-end;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
align-content: flex-start;
}
.title {
display: flex;
width: 40%;
justify-content: center;
align-items: flex-start;
flex-wrap: nowrap;
flex-direction: row;
align-content: flex-start;
position: relative;
height: 100%;
margin-top: 10px;
span {
font-size: 39px;
font-family: YouSheBiaoTiHei;
font-weight: 400;
color: rgba(51, 251, 254, 1.00);
}
}
}
</style>
帧动画组件封装
通过canvas依次加载动画实现帧动画效果。
<template>
<canvas ref="animation_canvas" class="animation_canvas" id="animation_canvas"></canvas>
</template>
<script>
import {link} from '@/config/config'
// 序列帧动画
export default {
name: "sequence",
data() {
return {}
},
props: {
// 文件目录
fileName: {
type: String,
default() {
return 'xuliezhen1/预合成 1_';
}
},
// 文件数量
fileLength: {
type: Number,
default() {
return 70;
}
},
// 动画间隔
IntervalTime: {
type: Number,
default() {
return 80;
}
},
},
mounted() {
var that = this;
that.Sequence()
},
methods: {
Sequence() {
var that = this;
//初始化参数
var canvas = null;
var ctx = null;
var sources = [];
//构建图片序列数据
for (var i = 0; i <= this.fileLength; i++) {
sources[i] = link + this.fileName + i + '.png';//根据项目修改
}
var width = this.$refs.animation_canvas.offsetWidth
var height = this.$refs.animation_canvas.offsetHeight
canvas = this.$refs.animation_canvas;
canvas.width = width;
canvas.height = height;
ctx = canvas.getContext("2d");
//预加载序列图片
function loadImages(sources, callback) {
var loadedImages = 0;
var numImages = 0;
var images = [];
// get num of sources
numImages = sources.length;
for (var i = 0, len = sources.length; i < len; i++) {
images[i] = new Image();
//当一张图片加载完成时执行
images[i].onload = function () {
//当所有图片加载完成时,执行回调函数callback
if (++loadedImages >= numImages) {
callback(images);
}
};
//把sources中的图片信息导入images数组
images[i].src = sources[i];
// console.log(images);
}
}
//播放图片动画
function playImages(images) {
var imageNum = images.length;
var imageNow = 0;
setInterval(function () {
ctx.fillStyle = "rgba(0,0,0,0)";
ctx.clearRect(0, 0, width, height);
ctx.fillRect(0, 0, width, height);
ctx.drawImage(images[imageNow], 0, 0, width, height);
imageNow++;
if (imageNow >= imageNum) {
imageNow = 0;
}
}, that.IntervalTime)
}
//ctx.globalAlpha=0.5
//执行图片预加载,加载完成后执行main
loadImages(sources, function (images) {
playImages(images)
});
}
},
}
</script>
<style lang="scss" scoped>
.animation_canvas {
position: absolute;
left: 0;
top: 0px;
width: 100%;
height: 100%;
z-index: -1;
}
</style>
更多数据可视化大屏顶部组件
源文件下载
文件包括头部效果代码 vue3 vite js nodejs 14
ae扫光动画源文件