当前位置: 首页 > 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.dtcms.com/a/297405.html

相关文章:

  • Vue2-VueRouter
  • [LeetCode]每日温度
  • 基于深度学习的图像分类:使用Vision Transformer(ViT)实现高效分类
  • 机器学习 KNN 算法,鸢尾花案例
  • Typecho多语言解决方案:从插件到主题的完整实现
  • 第5章 Excel公式与函数应用指南(1):公式和函数基础
  • C++ Qt6 CMake qml文件启动方式说明
  • 进阶向:基于Python的简易屏幕画笔工具
  • 萤石云替代产品摄像头方案萤石云不支持TCP本地连接-东方仙盟
  • Zabbix配置自动发现
  • 二分查找-268.丢失的数字-力扣(LeetCode)
  • 火候:烹饪的温度密码
  • DNF: Decouple and Feedback Network for Seeing in the Dark
  • Java线程基础面试复习笔记
  • 主要分布在背侧海马体(dHPC)CA1区域(dCA1)的时空联合细胞对NLP中的深层语义分析的积极影响和启示
  • 高级06-Java网络编程:从Socket到HTTP
  • 数据结构3-单双链表的泛型实现及ArrayList与LinkedList的区别
  • VUE懒加载(4种方式)
  • 深入理解 BIO、NIO、AIO
  • Java并发编程第十篇(ConcurrentHashMap组件分析)
  • Zabbix7设置告警
  • SQL基础⑭ | 变量、流程控制与游标篇
  • 从语言关联到事件推演的跃迁之路-语义图谱、知识图谱与事理图谱:认知的三维拼图
  • IA课程作业
  • C++调用GnuPlot一维绘图
  • 后端项目中大量 SQL 执行的性能优化
  • Oracle 19C Data Guard :从原理到实践的高可用解决方案
  • 在VSCode配置Java开发环境的保姆级教程(适配各类AI编程IDE)
  • CentOS8 使用 Docker 搭建 Jellyfin 家庭影音服务器
  • 电科金仓新一代数据库一体机:以 “云数据库 - AI 版” 引领 AI 时代数据库变革