当前位置: 首页 > news >正文

滚动提示组件

组件

<script setup lang="ts">
import { InfoCircleFilled } from '@ant-design/icons-vue';
import { ref, computed, onMounted } from 'vue';const props = defineProps<{dataList?: string[];
}>();const list = computed(() =>props.dataList?.length ? props.dataList : ['暂无预警']
);const currentIndex = ref(0);onMounted(() => {setInterval(() => {currentIndex.value = (currentIndex.value + 1) % list.value.length;}, 5000); // 每 5 秒切换一条
});
</script>
<template><div class="tishi-vertical"><div class="icon"><InfoCircleFilled />  </div><sapn class="label"> 预警提醒</sapn><div class="labelL">|</div><div class="scroll-box"><div class="scroll-list"><div class="scroll-item" v-for="(item, index) in list" :key="index">{{ item }}</div><!-- 关键:复制一遍数据以实现循环无缝 --><div class="scroll-item" v-for="(item, index) in list" :key="'copy-' + index">{{ item }}</div></div></div></div>
</template><style scoped lang="less">
.tishi-vertical {margin-left: 25px;display: flex;align-items: center;overflow: hidden;font-size: 14px;.icon {font-size: 20px;color: #faad14;margin-right: 6px;svg {path {fill: white;}}}.labelL {margin-right: 20px;margin-left: 20px;}.label {margin-right: 8px;color: #faad14;font-weight: 600;font-size: 14px;}.scroll-box {height: 26px * 1; // 同时显示1条overflow: hidden;flex: 1;position: relative;.scroll-list {display: flex;flex-direction: column;animation: scroll-up 5s linear infinite; // 控制滚动速度.scroll-item {height: 24px;line-height: 24px;white-space: nowrap;font-weight: 400;}}}@keyframes scroll-up {0% {transform: translateY(0%);}100% {transform: translateY(-50%); // 滚动一半,前提是数据重复一遍}}
}</style>

引入

  <!-- 提示 --><WarningNotice :dataList="DATANAMELIST" />

传入数据格式

import { ref, onMounted } from 'vue';

const DATANAMELIST = ref<string[]>([]);

onMounted(() => {

 DATANAMELIST.value=  ['内容1','内容2','内容3']

});

http://www.lryc.cn/news/599140.html

相关文章:

  • MinIO:云原生对象存储的终极指南
  • GPU服务器与PC 集群(PC农场):科技算力双子星
  • 【PZ-KU060-KFB】——Kintex UltraScale 纯 FPGA 开发平台,释放高速并行计算潜能,高性价比的 FPGA 解决方案
  • 缓存HDC内容用于后续Direct2D绘制.
  • 云原生介绍
  • 云原生可观测-日志观测(Loki)最佳实践
  • 云原生 —— K8s 容器编排系统
  • iOS 日志查看实战指南,如何全面获取与分析 App 和系统日志
  • 单片机(STM32-ADC模数转换器)
  • 清理DNS缓存
  • 【物联网】基于树莓派的物联网开发【17】——物联网通信协议MQTT基础知识
  • 图论:并查集
  • 璞致 PZSDR-P101:ZYNQ7100+AD9361 架构软件无线电平台,重塑宽频信号处理范式
  • 图论:最小生成树
  • OneCode3.0 Gallery 组件前后端映射机制:从注解配置到前端渲染的完整链路
  • js基础概念-1
  • Mysql 日志 binlog redolog
  • onenav部署教程
  • 【氮化镓】GaN取代GaAs作为空间激光无线能量传输光伏转换器材料
  • 顺应AI浪潮,电科金仓数据库再创辉煌
  • Gitee如何成为国内企业DevOps转型的首选平台?
  • springboot(3.4.8)整合mybatis
  • 机器学习(一)KNN,K近邻算法(K-Nearest Neighbors)
  • 进程控制->进程替换(Linux)
  • 【深度学习优化算法】09:Adadelta算法
  • RocketMQ5.3.1的安装
  • AI小智源码分析——音频部分(一)
  • 医疗数据挖掘Python机器学习案例
  • 【办公类-107-03】20250725通义万相2.1“动物拟人化”视频,优化关键词(图片转视频MP4转gif))
  • 【Qt】QProcess启动第三方程序或脚本失败