当前位置: 首页 > 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.xdnf.cn/news/1183231.html

相关文章:

  • JavaScript 数组的 every() 和 some() 方法使用
  • Microsoft-DNN NTLM暴露漏洞复现(CVE-2025-52488)
  • JAVA知识点(三):Spring与ORM框架
  • Linux下使用VSCode配置GCC环境与调试指南
  • 深入探索嵌入式仿真教学:以酒精测试仪实验为例的高效学习实践
  • 验证 GitHub Pages 的自定义域(Windows)
  • 《Uniapp-Vue 3-TS 实战开发》自定义年月日时分秒picker组件
  • SaaS型小程序自动化发布解决方案
  • VoWiFi技术深度解析:架构、流程与演进
  • 深入解析HBase如何保证强一致性:WAL日志与MVCC机制
  • 如何在 Ubuntu 24.04 或 22.04 上安装和使用 GDebi
  • 《剑指offer》-数据结构篇-链表
  • 【初识数据结构】CS61B中的快速排序
  • 【集合】JDK1.8 HashMap 底层数据结构深度解析
  • 在VSCode配置Java开发环境的保姆级教程(适配各类AI编程IDE)
  • “磁”力全开:钕铁硼重塑现代科技生活
  • 73. 矩阵置零
  • Franky — 边缘计算智能语音助手 / Edge‑Computing Smart Voice Assistant
  • CY5-OVA科研方向,星戈瑞荧光
  • uniapp小程序上传图片并压缩
  • 图片查重从设计到实现(3)图片存储MinIO 应用介绍及 Docker 环境下的安装部署
  • Java学习第七十五部分——Docker
  • 【前端】JavaScript文件压缩指南
  • Gitee Test:国产软件测试平台如何筑牢关键领域数字安全屏障
  • Spring Boot License 认证系统
  • c# openxml 打开加密 的word读取内容
  • SQL性能优化
  • 基于开源链动2+1模式AI智能名片S2B2C商城小程序的私域流量池用户运营研究
  • 如何实现缓存音频功能(App端详解)
  • vscode 字体的跟换