CSS+Vue3 + TS + Setup 10种生产级可视化循环动效合集(大屏高端交互、开箱复用)-附完整示例

效果

目录

效果

一、前言

动效完整清单(10种大屏专属高端动效)

二、核心实现原理

三、全局合集预览页面(VisualAll.vue)

四、十大独立模块化动效组件(按需单独引入、样式完全隔离)

[1、脉冲闪烁告警灯 VisualPulse.vue](#1、脉冲闪烁告警灯 VisualPulse.vue)

[2、双层波纹雷达扩散 VisualRadar.vue](#2、双层波纹雷达扩散 VisualRadar.vue)

[3、线性流光扫描条 VisualScanLine.vue](#3、线性流光扫描条 VisualScanLine.vue)

[4、四边循环流光边框 VisualStreamBorder.vue](#4、四边循环流光边框 VisualStreamBorder.vue)

[5、骨架屏微光流动 VisualSkeleton.vue](#5、骨架屏微光流动 VisualSkeleton.vue)

[6、环形旋转Loading VisualCircleLoading.vue](#6、环形旋转Loading VisualCircleLoading.vue)

[7、虚线流动边框 VisualDashBorder.vue](#7、虚线流动边框 VisualDashBorder.vue)

[8、边角高亮闪烁卡片 VisualCornerCard.vue](#8、边角高亮闪烁卡片 VisualCornerCard.vue)

[9、文字渐变浮现 VisualTextFade.vue](#9、文字渐变浮现 VisualTextFade.vue)

[10、管线粒子单向流动 VisualPipeLine.vue](#10、管线粒子单向流动 VisualPipeLine.vue)

五、工程化高阶组件封装(全局可配置复用)

1、项目目录规范

[2、统一入口 index.ts](#2、统一入口 index.ts)

3、可配置组件标准模板(示例:脉冲告警灯)

标准模板调用示例(局部按需引入)

[4、全局注册 main.ts](#4、全局注册 main.ts)

5、业务页面调用示例

六、业务场景总结

七、结语

欢迎关注:【前端小知识营地】


一、前言

开发数据可视化大屏、IoT监控平台的前端开发者常会遇到一个问题:基础的呼吸灯动画仅能满足极简的状态展示需求,一旦涉及数据扫描、链路流转、模块高亮、异常告警、页面加载等高频可视化场景,原生动画效果会显得生硬廉价,无法支撑高端大屏的视觉质感。

此前主流的基础呼吸灯动效,适配场景单一,仅适用于轻量化状态提示,无法满足商业化可视化大屏的高阶视觉需求。基于多个商业大屏项目的实战沉淀,本文整理出10种生产级高端可视化循环动效,全覆盖大屏常用交互场景。

整套动效方案基于 Vue3 + TS + Script Setup 语法开发,依托原生 CSS3 实现,无需引入任何第三方动画库,具备动画可启停、参数可自定义、深色场景适配、轻量化高性能等优势。文章配套全局合集预览页、10套独立拆分组件、可配置通用模板、全局注册方案、完整业务示例,覆盖调试、单用、复用、落地全流程,可直接用于商业项目上线。

动效完整清单(10种大屏专属高端动效)

  1. 脉冲闪烁告警灯(设备/数据异常告警)

  2. 双层波纹雷达扩散(数据点位扫描、在线广播)

  3. 线性流光扫描条(数据通道、进度加载)

  4. 四边循环流光边框(核心数据模块高亮)

  5. 骨架屏微光流动(页面/卡片加载占位)

  6. 环形旋转Loading(全局/接口加载等待)

  7. 虚线流动边框(草稿/待审核状态标识)

  8. 边角高亮闪烁卡片(轻量化重点提示)

  9. 文字渐变浮现动画(状态文本动态展示)

  10. 管线粒子单向流动(数据流/信号传输模拟)

二、核心实现原理

本文10种高端可视化动效均基于原生CSS3实现,无第三方依赖、渲染性能优异,支持页面长期驻屏展示,不会出现卡顿、闪烁、错位等问题,完美适配数据大屏常驻渲染的业务特性。所有复杂动效均由六大核心CSS动画原理组合拓展而成,开发者掌握核心原理后,可自主拓展、定制各类个性化可视化动画。

  • 透明度周期变化:通过透明度明暗交替,实现文字浮现、轻量闪烁效果。

  • 光晕阴影渐变:依托动态内外阴影,实现脉冲扩散、发光高亮质感。

  • 缩放形变变换:元素周期性缩放,打造立体波纹、动态呼吸层次。

  • 角度旋转变换:360°循环旋转,实现环形加载、雷达扫描动效。

  • 渐变位移动画:背景渐变偏移滚动,实现流光、微光高级质感。

  • 伪元素分层渲染:双层伪元素叠加,实现复杂流光、双层波纹结构。

所有动画统一通过 animation-play-state 属性控制启停状态,相较于原生JS操作样式切换动画,原生CSS动画性能更稳定、过渡更丝滑,适配大屏长时间驻场展示的业务需求。

三、全局合集预览页面(VisualAll.vue)

本页面集中集成全部10种可视化动效,主要用于本地效果预览、多动效对比、整体调试校验,无需单独引入组件,直接运行即可查看所有动效的完整展示效果,极大提升开发调试效率。

Go 复制代码
<template>
  <div class="visual-container">
    <h2 class="title">Vue3 10种可视化高端动效合集</h2>

    <div class="item">
      <div class="light-pulse"></div>
      <span>1. 脉冲闪烁告警灯</span>
    </div>
    <div class="item">
      <div class="radar-wrap">
        <div class="radar-item"></div>
        <div class="radar-item delay-item"></div>
      </div>
      <span>2. 双层波纹雷达扩散</span>
    </div>
    <div class="item">
      <div class="scan-line"></div>
      <span>3. 线性流光扫描条</span>
    </div>
    <div class="item">
      <div class="stream-border">4. 四边循环流光边框</div>
    </div>
    <div class="item">
      <div class="skeleton-item"></div>
      <span>5. 骨架屏微光流动</span>
    </div>
    <div class="item">
      <div class="circle-loading"></div>
      <span>6. 环形旋转Loading</span>
    </div>
    <div class="item">
      <div class="dash-border">7. 虚线流动边框</div>
    </div>
    <div class="item">
      <div class="corner-card">8. 边角高亮闪烁卡片</div>
    </div>
    <div class="item">
      <span class="text-fade">9. 文字渐变浮现动画</span>
    </div>
    <div class="item">
      <div class="pipe-wrap">
        <div class="pipe-dot"></div>
      </div>
      <span>10. 管线粒子单向流动</span>
    </div>
  </div>
</template>

<script setup lang="ts"></script>

<style scoped>
.visual-container {
  width: 100%;
  padding: 60px;
  background: #0b1322;
  box-sizing: border-box;
}
.title {
  color: #fff;
  margin-bottom: 40px;
  font-size: 22px;
}
.item {
  display: flex;
  align-items: center;
  margin-bottom: 36px;
  gap: 20px;
  color: #fff;
  font-size: 14px;
}

/* 1.脉冲告警灯 | 强化扩散光晕、动画层次感 */
.light-pulse {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f53f3f;
  will-change: box-shadow;
  animation: pulse 1.2s ease-in-out infinite alternate;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 63, 63, 0.35); transform: scale(0.95); }
  100% { box-shadow: 0 0 0 16px rgba(245, 63, 63, 0); transform: scale(1); }
}

/* 2.雷达波纹 | 强化双层扩散对比度,动画更醒目 */
.radar-wrap {width: 60px;height: 60px;position: relative;}
.radar-item {
  position: absolute;top: 0;left: 0;width: 100%;height: 100%;
  border-radius: 50%;border: 1px solid #409eff;
  animation: radar 2.5s linear infinite;
}
.radar-item.delay-item {animation-delay: 1.2s;}
@keyframes radar {
  0% { transform: scale(0.2); opacity: 0.8; }
  100% { transform: scale(1); opacity: 0; }
}

/* 3.流光扫描条 | 增强流光亮度、加大位移幅度 */
.scan-line {
  width: 200px;height: 4px;border-radius: 2px;
  background: #192a45;
  background-image: linear-gradient(90deg, transparent, #69b1ff, transparent);
  background-size: 300% 100%;
  animation: lineScan 2s linear infinite;
}
@keyframes lineScan {
  0% { background-position: -300px 0; }
  100% { background-position: 300px 0; }
}

/* 4.四边流光边框 | 强化渐变流动速度与色彩饱和度 */
.stream-border {
  width: 260px;padding: 16px;border-radius: 8px;
  background: #0b1322;color: #fff;position: relative;z-index:1;
}
.stream-border::before {
  content:"";position:absolute;left:-2px;top:-2px;right:-2px;bottom:-2px;
  background: linear-gradient(120deg, #409eff, #00b42a, #13c2c2, #409eff);
  background-size: 300% 300%;
  border-radius: 9px;
  z-index: -1;
  animation: borderStream 4s linear infinite;
}
@keyframes borderStream {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 5.骨架微光 | 提升明暗对比度,流动效果更清晰 */
.skeleton-item {
  width: 100%;height: 80px;border-radius: 6px;
  background: #152035;
  background-image: linear-gradient(90deg, #152035, #2a3b58, #152035);
  background-size: 200% 100%;
  animation: skeletonFlow 1.5s linear infinite;
}
@keyframes skeletonFlow {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 6.环形加载 | 提升旋转流畅度、强化高亮色差 */
.circle-loading {
  width: 36px;height: 36px;
  border: 3px solid rgba(64, 158, 255, 0.15);
  border-top-color: #409eff;
  border-radius: 50%;
  animation: circleRotate 1s linear infinite;
}
@keyframes circleRotate {
  100% { transform: rotate(360deg); }
}

/* 7.虚线流动边框 | 强化色彩动态对比,动画质感升级 */
.dash-border {
  width: 200px;padding: 12px;color: #999;
  border: 2px dashed #722ed1;border-radius: 6px;
  animation: dashMove 2s linear infinite;
}
@keyframes dashMove {
  0% { border-color: #722ed1 transparent transparent transparent; }
  25% { border-color: transparent #722ed1 transparent transparent; }
  50% { border-color: transparent transparent #722ed1 transparent; }
  75% { border-color: transparent transparent transparent #722ed1; }
}

/* 8.边角高亮卡片 | 强化明暗闪烁反差,提示感更强 */
.corner-card {
  width: 220px;padding: 20px;background: #0b1322;
  color: #fff;border-radius: 8px;position: relative;
}
.corner-card::before,.corner-card::after {
  content: "";position: absolute;width: 12px;height: 12px;
  border: 2px solid #ffe500;opacity: 0.6;
  animation: cornerShine 1.5s ease-in-out infinite alternate;
}
.corner-card::before {top: 0;left: 0;border-right: none;border-bottom: none;}
.corner-card::after {bottom: 0;right: 0;border-left: none;border-top: none;animation-delay: 0.7s;}
@keyframes cornerShine {
  0% { opacity: 0.15; }
  100% { opacity: 1; }
}

/* 9.文字渐变浮现 | 优化缩放与透明度差值,动态感拉满 */
.text-fade {
  font-size: 16px;color: #409eff;
  animation: textFade 2s ease-in-out infinite alternate;
}
@keyframes textFade {
  0% { opacity: 0.25; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

/* 10.管线粒子流动 | 强化粒子明暗变化,轨迹更清晰 */
.pipe-wrap {
  width: 200px;height: 4px;
  background: rgba(64, 158, 255, 0.1);
  border-radius: 2px;position: relative;
}
.pipe-dot {
  position: absolute;left: 0;top: 50%;
  width: 8px;height: 8px;border-radius: 50%;
  background: #409eff;
  transform: translate(0, -50%);
  animation: pipeMove 2s linear infinite;
}
@keyframes pipeMove {
  0% { left: 0; opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { left: 100%; opacity: 0.2; transform: scale(0.8); }
}
</style>

四、十大独立模块化动效组件(按需单独引入、样式完全隔离)

为适配前端工程化模块化开发规范,本文将10种动效全部拆分为独立单文件组件 ,组件样式完全隔离、互不耦合依赖,开发者可根据业务页面需求按需单独引入,无需全局加载冗余组件。所有组件兼容性强,可无缝适配所有 Vue3+TS 前端项目,技术规范统一、运行性能稳定,多组件混用不会出现样式污染、渲染冲突等问题。

1、脉冲闪烁告警灯 VisualPulse.vue

高频明暗交替告警效果,视觉警示性强,适用于各类项目的数据异常、设备故障、状态离线等高亮提示场景。依托CSS原生opacity与阴影缩放特性实现明暗扩散循环,节奏醒目、适配性广。

Go 复制代码
<template>
  <div class="pulse-box" :class="{ pause: !active }">
    <div class="pulse-dot"></div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    color?: string
    size?: number
  }>(),
  {
    active: true,
    color: '#f53f3f',
    size: 30
  }
)
</script>

<style scoped>
.pulse-box {
  position: relative;
  width: v-bind(size + 'px');
  height: v-bind(size + 'px');
  transform: translateZ(0);
  will-change: transform, box-shadow;
}

.pulse-dot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: v-bind(color);
  box-shadow: 0 0 6px v-bind(color);
  animation: pulseAnim 1.2s ease-in-out infinite alternate;
  opacity: 0.9;
}

/* 动画暂停置灰样式,区分运行/静止状态 */
.pulse-box.pause .pulse-dot {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 脉冲告警动画
 * 圆点缩放+光晕扩散交替变化,适配设备异常、数据告警高亮场景
 * 采用静态关键帧,适配Vue3渲染机制,保证动画运行稳定
 */
@keyframes pulseAnim {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(245, 63, 63, 0.6);
    opacity: 0.9;
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 18px rgba(245, 63, 63, 0);
    opacity: 1;
  }
}
</style>

2、双层波纹雷达扩散 VisualRadar.vue

双层环形扩散扫描效果,科技感十足,适用于点位探测、设备在线扫描、区域广播监控场景。通过双层组件延时加载+缩放透明度过渡,实现层层递进的雷达扩散动态效果。

Go 复制代码
<template>
  <div class="ripple-box" :class="{ pause: !active }">
    <div class="ripple"></div>
    <div class="ripple"></div>
    <div class="center-dot"></div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    size?: number
  }>(),
  {
    active: true,
    size: 60
  }
)
</script>

<style scoped>
.ripple-box {
  position: relative;
  width: v-bind(size + 'px');
  height: v-bind(size + 'px');
  transform: translateZ(0);
  will-change: transform;
}

.center-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #409eff;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  box-shadow: 0 0 8px #409eff;
}

.ripple {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid #409eff;
  animation: rippleAnim 2s linear infinite;
  opacity: 0.9;
}

/* 双层波纹延时执行,形成递进扩散视觉效果 */
.ripple:nth-child(2) {
  animation-delay: 0.6s;
}

/* 动画暂停置灰样式,统一全局状态展示逻辑 */
.ripple-box.pause .ripple {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 双层雷达扩散动画
 * 双层圆环由内向外缩放淡化,模拟雷达扫描、点位探测效果
 * 静态关键帧配置,无动态变量侵入,适配长期驻屏展示
 */
@keyframes rippleAnim {
  0% {
    transform: scale(0.5);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}
</style>

3、线性流光扫描条 VisualScanLine.vue

细长流光滚动动效,简洁高级,适用于数据通道扫描、进度加载、状态轮询提示场景。依靠背景渐变百分比位移动画,实现无缝顺滑的流光滑动效果,轻量化无性能损耗。

Go 复制代码
<template>
  <div class="scan-box" :class="{ pause: !active }">
    <div class="scan-line" :style="{ width: width + 'px', height: height + 'px' }"></div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    width?: number
    height?: number
  }>(),
  {
    active: true,
    width: 200,
    height: 4
  }
)
</script>

<style scoped>
.scan-box {
  transform: translateZ(0);
  will-change: background-position;
  display: inline-block;
}

.scan-line {
  width: 100%;
  height: 100%;
  border-radius: 2px;
  background: #e8f3ff;
  background-image: linear-gradient(90deg, transparent, #409eff, transparent);
  background-size: 300% 100%;
  animation: scanAnim 2s linear infinite;
  opacity: 0.9;
}

/* 动画暂停置灰样式,实现运行与静止状态视觉区分 */
.scan-box.pause .scan-line {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 流光扫描动画
 * 渐变背景横向循环位移,模拟数据通道扫描、加载流转效果
 * 固定关键帧参数,动画节奏均匀顺滑,适配常驻页面展示
 */
@keyframes scanAnim {
  0% { background-position: -300px 0; opacity: 0.9; }
  100% { background-position: 300px 0; opacity: 1; }
}
</style>

4、四边循环流光边框 VisualStreamBorder.vue

边框渐变环绕高亮动效,视觉聚焦性强,适用于核心数据卡片、重点模块高亮、弹窗聚焦场景。通过伪元素全覆盖渲染+渐变角度偏移,实现四边无限循环流光质感。

Go 复制代码
<template>
  <div class="border-box" :class="{ pause: !active }" :style="{ width: width + 'px' }">
    <slot>核心数据模块</slot>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    width?: number
  }>(),
  {
    active: true,
    width: 260
  }
)
</script>

<style scoped>
.border-box {
  position: relative;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  color: #333;
  z-index: 1;
  transform: translateZ(0);
  will-change: background-position;
}

.border-box::before {
  content: "";
  position: absolute;
  left: -2px;
  top: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(120deg, #409eff, #00b42a, #13c2c2, #409eff);
  background-size: 300% 300%;
  border-radius: 9px;
  z-index: -1;
  animation: borderAnim 4s linear infinite;
  opacity: 0.9;
}

/* 动画暂停置灰样式,伪元素动画状态同步受控 */
.border-box.pause::before {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 四边流光边框动画
 * 渐变背景循环位移流转,实现边框环绕流光效果,聚焦核心模块
 * 静态渐变关键帧,跨场景渲染效果统一,无样式错乱问题
 */
@keyframes borderAnim {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
</style>

5、骨架屏微光流动 VisualSkeleton.vue

轻量化占位加载动效,适用于卡片、列表、图片等数据未加载完成的占位场景。依托双层背景渐变横向偏移,模拟自然微光流淌效果,替代传统生硬的静态骨架屏。

Go 复制代码
<template>
  <div class="skeleton-box" :class="{ pause: !active }">
    <div class="skeleton-item" :style="{ height: height + 'px' }"></div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    height?: number
  }>(),
  {
    active: true,
    height: 80
  }
)
</script>

<style scoped>
.skeleton-box {
  width: 300px;
  transform: translateZ(0);
  will-change: background-position;
}

.skeleton-item {
  width: 100%;
  border-radius: 6px;
  background: #f5f7fa;
  background-image: linear-gradient(90deg, #f5f7fa, #e4e9f2, #f5f7fa);
  background-size: 200% 100%;
  animation: skeletonAnim 1.5s linear infinite;
  opacity: 0.9;
}

/* 动画暂停置灰样式,统一组件状态交互逻辑 */
.skeleton-box.pause .skeleton-item {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 骨架微光流动动画
 * 浅色系渐变横向滚动,模拟数据加载占位微光效果
 * 固定关键帧参数,动画流畅稳定,适配各类加载占位场景
 */
@keyframes skeletonAnim {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
</style>

6、环形旋转Loading VisualCircleLoading.vue

简约商务风环形加载动画,适用于接口请求、页面初始化、弹窗等待场景。通过360°匀速旋转变换,搭配明暗色差对比,实现简洁高级的加载状态提示。

Go 复制代码
<template>
  <div class="loading-box" :class="{ pause: !active }">
    <div class="circle-loading" :style="{ width: size + 'px', height: size + 'px' }"></div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    size?: number
  }>(),
  {
    active: true,
    size: 36
  }
)
</script>

<style scoped>
.loading-box {
  display: inline-block;
  transform: translateZ(0);
  will-change: transform;
}

.circle-loading {
  width: 100%;
  height: 100%;
  border: 3px solid #e8f3ff;
  border-top-color: #409eff;
  border-radius: 50%;
  animation: rotateAnim 1s linear infinite;
  opacity: 0.9;
}

/* 动画暂停置灰样式,和全局组件状态展示保持一致 */
.loading-box.pause .circle-loading {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 环形旋转加载动画
 * 顶部高亮色块360°匀速旋转,适配接口请求、页面初始化等待场景
 * 极简关键帧配置,轻量化无性能消耗,长期运行稳定
 */
@keyframes rotateAnim {
  100% { transform: rotate(360deg); }
}
</style>

7、虚线流动边框 VisualDashBorder.vue

虚线循环跑动边框效果,弱提醒质感适中,适用于草稿状态、待审核、未完成任务标识场景。通过动态切换四向虚线颜色,实现边框持续流动的视觉动态。

Go 复制代码
<template>
  <div class="dash-box" :class="{ pause: !active }" :style="{ width: width + 'px' }">
    <slot>待审核状态</slot>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    width?: number
  }>(),
  {
    active: true,
    width: 200
  }
)
</script>

<style scoped>
.dash-box {
  display: inline-block;
  padding: 12px;
  color: #333;
  border: 2px dashed #722ed1;
  border-radius: 6px;
  transform: translateZ(0);
  will-change: border-color;
  animation: dashAnim 2s linear infinite;
  opacity: 0.9;
}

/* 动画暂停置灰样式,静止状态视觉弱化展示 */
.dash-box.pause {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 虚线流动边框动画
 * 四向边框颜色循环切换,模拟边框跑动效果,适配草稿、待审核状态
 * 纯静态关键帧结构,适配全版本Vue3,渲染效果无差异
 */
@keyframes dashAnim {
  0% { border-color: #722ed1 transparent transparent transparent; }
  25% { border-color: transparent #722ed1 transparent transparent; }
  50% { border-color: transparent transparent #722ed1 transparent; }
  75% { border-color: transparent transparent transparent #722ed1; }
}
</style>

8、边角高亮闪烁卡片 VisualCornerCard.vue

四角定点高亮闪烁效果,低干扰、重点突出,适用于重点提示、告警卡片、核心数据置顶场景。利用对角双伪元素延时交替闪烁,打造精致的高亮提示动效。

Go 复制代码
<template>
  <div class="corner-box" :class="{ pause: !active }" :style="{ width: width + 'px' }">
    <slot>重点提示卡片</slot>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    width?: number
  }>(),
  {
    active: true,
    width: 220
  }
)
</script>

<style scoped>
.corner-box {
  position: relative;
  padding: 20px;
  background: #fff;
  color: #333;
  border-radius: 8px;
  transform: translateZ(0);
  will-change: opacity;
}

.corner-box::before,.corner-box::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #ffe500;
  opacity: 0.8;
  animation: cornerAnim 1.5s ease-in-out infinite alternate;
}

.corner-box::before {top: 0;left: 0;border-right: none;border-bottom: none;}
.corner-box::after {bottom: 0;right: 0;border-left: none;border-top: none;animation-delay: 0.7s;}

/* 动画暂停置灰样式,双伪元素动画同步暂停弱化 */
.corner-box.pause::before,.corner-box.pause::after {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 边角高亮闪烁动画
 * 对角边角明暗交替闪烁,低干扰突出卡片重点,适配提示、告警卡片场景
 * 固定动画参数,闪烁节奏柔和均匀,长期展示无视觉疲劳
 */
@keyframes cornerAnim {
  0% { opacity: 0.2; }
  100% { opacity: 1; }
}
</style>

9、文字渐变浮现 VisualTextFade.vue

文本动态呼吸效果,柔和高级,适用于状态提示语、动态文案、数据更新提醒场景。结合透明度渐变+微小缩放形变,实现细腻的文字动态浮现效果。

Go 复制代码
<template>
  <div class="text-box" :class="{ pause: !active }">
    <span class="text-fade" :style="{ fontSize: fontSize + 'px', color: color }">
      <slot>数据加载完成</slot>
    </span>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    color?: string
    fontSize?: number
  }>(),
  {
    active: true,
    color: '#409eff',
    fontSize: 16
  }
)
</script>

<style scoped>
.text-box {
  display: inline-block;
  transform: translateZ(0);
  will-change: opacity, transform;
}

.text-fade {
  animation: textAnim 2s ease-in-out infinite alternate;
  opacity: 0.9;
}

/* 动画暂停置灰样式,统一全局组件状态交互逻辑 */
.text-box.pause .text-fade {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 文字渐变浮现动画
 * 文字透明度+微小缩放交替变化,打造柔和呼吸动态效果
 * 适配状态提示、动态文案展示,动画细腻无突兀感
 */
@keyframes textAnim {
  0% { opacity: 0.3; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}
</style>

10、管线粒子单向流动 VisualPipeLine.vue

粒子定点滑移传输动效,科技感拉满,适用于数据链路、信号传输、设备通讯流转模拟场景。通过定点小球位移动画+明暗缩放变化,复刻真实数据流传输动态。

Go 复制代码
<template>
  <div class="pipe-box" :class="{ pause: !active }" :style="{ width: width + 'px' }">
    <div class="pipe-dot" :style="{ width: dotSize + 'px', height: dotSize + 'px', background: color }"></div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, withDefaults } from 'vue'
const props = withDefaults(
  defineProps<{
    active?: boolean
    color?: string
    width?: number
    dotSize?: number
  }>(),
  {
    active: true,
    color: '#409eff',
    width: 200,
    dotSize: 8
  }
)
</script>

<style scoped>
.pipe-box {
  position: relative;
  height: 4px;
  transform: translateZ(0);
  will-change: left, transform, opacity;
}

.pipe-box {
  width: 100%;
  background: #e8f3ff;
  border-radius: 2px;
}

.pipe-dot {
  position: absolute;
  left: 0;
  top: 50%;
  border-radius: 50%;
  transform: translate(0, -50%);
  animation: pipeAnim 2s linear infinite;
  opacity: 0.9;
}

/* 动画暂停置灰样式,数据流动画状态统一管控 */
.pipe-box.pause .pipe-dot {
  animation-play-state: paused;
  opacity: 0.2;
}

/**
 * 管线粒子流动动画
 * 粒子沿管线横向位移,搭配缩放明暗变化,模拟数据传输、信号流转效果
 * 关键帧参数固定,动画轨迹稳定,适配大屏链路可视化场景
 */
@keyframes pipeAnim {
  0% { left: 0; opacity: 0.5; transform: scale(0.8) translateY(-50%); }
  50% { opacity: 1; transform: scale(1.2) translateY(-50%); }
  100% { left: 100%; opacity: 0.5; transform: scale(0.8) translateY(-50%); }
}
</style>

五、工程化高阶组件封装(全局可配置复用)

1、项目目录规范

所有动效组件统一存放,符合Vue3工程化规范,支持全局注册、按需引入:

Go 复制代码
src/components/VisualAnimation/
├─ index.ts // 统一导出入口
├─ VisualAll.vue // 全局预览页
├─ VisualPulse.vue
├─ VisualRadar.vue
├─ VisualScanLine.vue
├─ VisualStreamBorder.vue
├─ VisualSkeleton.vue
├─ VisualCircleLoading.vue
├─ VisualDashBorder.vue
├─ VisualCornerCard.vue
├─ VisualTextFade.vue
└─ VisualPipeLine.vue

2、统一入口 index.ts

Go 复制代码
import VisualPulse from './VisualPulse.vue'
import VisualRadar from './VisualRadar.vue'
import VisualScanLine from './VisualScanLine.vue'
import VisualStreamBorder from './VisualStreamBorder.vue'
import VisualSkeleton from './VisualSkeleton.vue'
import VisualCircleLoading from './VisualCircleLoading.vue'
import VisualDashBorder from './VisualDashBorder.vue'
import VisualCornerCard from './VisualCornerCard.vue'
import VisualTextFade from './VisualTextFade.vue'
import VisualPipeLine from './VisualPipeLine.vue'

// 批量组件对象,用于全局批量注册
export const VisualAnimationComponents = {
  VisualPulse,
  VisualRadar,
  VisualScanLine,
  VisualStreamBorder,
  VisualSkeleton,
  VisualCircleLoading,
  VisualDashBorder,
  VisualCornerCard,
  VisualTextFade,
  VisualPipeLine
}

// 单个组件按需导出,用于局部页面按需引入
export {
  VisualPulse,
  VisualRadar,
  VisualScanLine,
  VisualStreamBorder,
  VisualSkeleton,
  VisualCircleLoading,
  VisualDashBorder,
  VisualCornerCard,
  VisualTextFade,
  VisualPipeLine
}

// 默认批量导出,适配统一导入场景
export default VisualAnimationComponents

3、可配置组件标准模板(示例:脉冲告警灯)

所有组件均支持:尺寸、颜色、动画时长、启停状态自定义,下面为通用规范模板。

Go 复制代码
<template>
  <div 
    class="visual-pulse"
    :style="{ width: size + 'px', height: size + 'px', background: color, animation-duration: duration + 's' }"
    :class="[active ? '' : 'pause']"
  ></div>
</template>

<script setup lang="ts">
/**
 * 可视化动效组件通用标准模板
 * 所有动效组件均遵循统一工程化规范,支持参数自定义、动画启停、样式隔离
 * @param active 动画启停核心状态
 * @param size 组件自定义尺寸
 * @param color 组件主题配色
 * @param duration 动画自定义时长
 */
interface Props {
  active: boolean
  size?: number
  color?: string
  duration?: number
}

// 统一默认参数配置,适配大屏可视化视觉规范
const props = withDefaults(defineProps<Props>(), {
  size: 30,
  color: '#f53f3f',
  duration: 1.2
})
</script>

<style scoped>
.visual-pulse {
  border-radius: 50%;
  will-change: box-shadow, transform;
  animation: pulse-anim infinite alternate ease-in-out;
}

/* 动画暂停通用样式 */
.visual-pulse.pause {
  animation-play-state: paused;
  opacity: 0.2;
}

@keyframes pulse-anim {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 63, 63, 0.35);
    transform: scale(0.95);
  }
  100% {
    box-shadow: 0 0 0 16px rgba(245, 63, 63, 0);
    transform: scale(1);
  }
}
</style>
标准模板调用示例(局部按需引入)
Go 复制代码
<template>
  <div class="visual-container">
    <h2 class="title">可配置标准模板 - 脉冲告警灯调用示例</h2>

    <div class="item">
      <!-- 1.基础默认调用:使用组件默认参数 -->
      <VisualPulse :active="true" />
      <span>基础默认样式(默认红色、30px尺寸、1.2s动画)</span>
    </div>

    <div class="item">
      <!-- 2.自定义参数调用:适配业务个性化需求 -->
      <VisualPulse 
        :active="true" 
        size="36" 
        color="#00b42a" 
        :duration="1.5" 
      />
      <span>自定义样式(绿色、36px尺寸、1.5s慢速动画)</span>
    </div>

    <div class="item">
      <!-- 3.动态启停调用:对接业务状态切换 -->
      <VisualPulse :active="isAlarm" size="40" />
      <span>动态交互告警灯(可手动切换动画启停)</span>
      <button class="demo-btn" @click="isAlarm = !isAlarm">
        {{ isAlarm ? '暂停动画' : '开启动画' }}
      </button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
// 按需引入标准模板组件
import VisualPulse from '@/components/VisualAnimation/VisualPulse.vue'

// 业务状态变量,可对接接口/页面状态动态控制动画
const isAlarm = ref(true)
</script>

<style scoped>
.visual-container {
  width: 100%;
  padding: 60px;
  background: #0b1322;
  box-sizing: border-box;
}
.title {
  color: #fff;
  margin-bottom: 40px;
  font-size: 22px;
}
.item {
  display: flex;
  align-items: center;
  margin-bottom: 36px;
  gap: 20px;
  color: #fff;
  font-size: 14px;
}
/* 交互按钮美化,适配深色背景 */
.demo-btn {
  padding: 6px 16px;
  background: #409eff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.demo-btn:hover {
  background: #66b1ff;
}
</style>

4、全局注册 main.ts

Go 复制代码
import { createApp } from 'vue'
import App from './App.vue'
import { VisualAnimationComponents } from '@/components/VisualAnimation'

const app = createApp(App)
Object.entries(VisualAnimationComponents).forEach(([key, component]) => {
  app.component(key, component)
})
app.mount('#app')

5、业务页面调用示例

Go 复制代码
<template>
  <div class="visual-container">
    <h2 class="title">业务页面完整调用示例</h2>

    <h3 class="sub-title">1. 组件基础默认用法</h3>
    <div class="item">
      <VisualPulse :active="true" />
      <span>脉冲告警灯(默认参数)</span>
    </div>
    <div class="item">
      <VisualRadar :active="true" />
      <span>双层雷达扩散(默认参数)</span>
    </div>
    <div class="item">
      <VisualCircleLoading :active="true" />
      <span>环形加载动画(默认参数)</span>
    </div>

    <h3 class="sub-title">2. 组件自定义参数用法(尺寸/颜色/动画速度)</h3>
    <div class="item">
      <VisualScanLine :active="true" width="300" :duration="1.8" />
      <span>自定义长度、慢速流光扫描条</span>
    </div>
    <div class="item">
      <VisualPulse :active="true" color="#00b42a" size="40" :duration="1.5" />
      <span>绿色大号慢速告警灯</span>
    </div>

    <h3 class="sub-title">3. 动态启停交互用法(真实业务场景)</h3>
    <div class="item">
      <VisualStreamBorder :active="borderStatus" width="300" />
      <span>核心模块高亮流光边框</span>
      <button class="demo-btn" @click="borderStatus = !borderStatus">
        {{ borderStatus ? '暂停动画' : '开启动画' }}
      </button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
// 全局注册组件后,业务页面可直接使用,无需逐个引入
const borderStatus = ref(true)
</script>

<style scoped>
.visual-container {
  width: 100%;
  padding: 60px;
  background: #0b1322;
  box-sizing: border-box;
}
.title {
  color: #fff;
  margin-bottom: 40px;
  font-size: 22px;
}
.sub-title {
  color: #fff;
  font-size: 16px;
  margin: 36px 0 20px;
}
.item {
  display: flex;
  align-items: center;
  margin-bottom: 36px;
  gap: 20px;
  color: #fff;
  font-size: 14px;
}
.demo-btn {
  padding: 6px 16px;
  background: #409eff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.demo-btn:hover {
  background: #66b1ff;
}
</style>

六、业务场景总结

本文10款可视化动效均为商业大屏项目实战沉淀的生产级方案,基于原生CSS3原生开发、零第三方依赖、性能轻量化,完美适配深色可视化场景,长期页面驻留无卡顿、无闪烁。所有组件采用标准化工程化封装,支持TS类型校验、动态启停、全参数自定义与样式隔离,兼顾实用性与可扩展性。轻量状态展示可搭配基础呼吸灯效果,数据大屏、IoT监控、工业可视化、高端后台系统可直接复用本文高阶动效,快速提升页面科技质感与视觉层次感,完全满足商用上线标准。

七、结语

整套可视化动效方案基于 Vue3 + TS + Script Setup 最新语法规范开发,代码整洁统一、注释清晰、可维护性高,完全符合企业级工程化开发标准。全文配套全局预览调试页、10套独立可运行动效组件、统一入口导出、全局注册方案以及完整业务示例,覆盖本地调试、单独使用、全局复用、业务落地全流程,开箱即用无需二次改造,是前端数据可视化开发的优质复用方案。

欢迎关注 :【前端小知识营地】

相关推荐
2601_955760071 小时前
如何用 Claude Opus 5 API 批量扩展长尾关键词和文章选题
前端·python·搜索引擎
KaMeidebaby1 小时前
卡梅德生物技术快报|bli亲和力检测gst:告别批量跑胶:BLI实时酶切监测技术加速GST融合蛋白下游流程优化
前端·网络·数据库·人工智能·算法
触底反弹2 小时前
🚀 删了数据刷新又回来?3 组件 × 4 回调 × 3 坑讲透 React 父子通信
前端·javascript·react.js
耳东小鹿3 小时前
对象常用方法
前端
程序员海军3 小时前
一个 AI 应用开发程序员的一天,都在屏幕前忙些什么?
前端·后端·程序员
程序员黑豆3 小时前
鸿蒙应用开发:Stack堆叠组件实战——实现微信消息角标效果
前端·harmonyos
夏幻灵3 小时前
浏览器原理深度解析:从输入 URL 到页面展现的全流程剖析
前端
闲猫4 小时前
Agent工程实践:从WorkFlow到多Agent协作的落地笔记
java·服务器·前端
带娃的IT创业者4 小时前
重新定义前端构建速度:深度解析 SWC 如何用 Rust 颠覆 JavaScript 工具链
前端·javascript·rust·前端构建·swc
happy_0x3f4 小时前
前端应用的离线暂停更新策略
开发语言·前端·php