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

Ant Design Vue notification自定义

<script setup>
import { onMounted, h, ref, watch, getCurrentInstance } from 'vue';
import { notification, Button } from 'ant-design-vue';
onMounted(() => {
const list = [{id: '11',warnLevel: '严重',...},...]showMessage(list);
});
function showMessage(){
for (const item of list) {const index = shownNotifications.findIndex((key) => key.id === item.id);if (index === -1) {const btn = () =>h('div',{class: 'notification-btn-wrapper', // 使用类名},[h(Button,{type: 'primary',size: 'small',onClick: () => handleConfirm(item),},{ default: () => '确认' }),]);notification.open({message: '门架交易数据异常',description: h('div', {}, [h('div', { class: 'ct-div' }, [h('div',[h('div', { class: 'label' }, '发生时间'),h('div', { class: 'value' }, item.statisticalDate)]),h('div',[h('div', { class: 'label' }, '预警级别'),h('div', { class: `value ${item.warnLevel === '严重' ? 'warnLevel' : ''}` }, item.warnLevel)]),]),h('div', { class: 'label' }, '异常描述'),h('div', { class: 'value warnDesc' }, item.warnDesc)]),btn,bottom: '10px',key: item.id,duration: null,placement: 'bottomRight',class: 'notification-custom-class',onClose: () => handleClose(item),});setShownNotifications(item.id);}}
}</script>
<style  lang="less">
.notification-custom-class {padding: 0;box-sizing: border-box;border-radius: 8px;.ant-notification-notice-content {.ant-notification-notice-message {height: 32px;border-bottom: 1px solid #0000000F;display: flex;align-items: center;padding-left: 10px;box-sizing: border-box;margin-bottom: 0;color: #262626;font-family: PingFang SC;font-weight: bold;font-size: 14px;}.ant-notification-notice-description {padding: 5px 10px;box-sizing: border-box;}.label {color: #00000072;font-family: PingFang SC;font-weight: 500;font-size: 12px;line-height: 22px;margin-bottom: 2px;}.value {opacity: 1;color: #262626;font-family: PingFang SC;font-weight: 500;font-size: 12px;line-height: 22px;margin-bottom: 2px;&:last-child {margin-bottom: 0;}}.ct-div {display: flex;align-items: center;> div {flex: 1;margin-right: 10px;&:last-child {margin-right: 0;}}}.warnDesc {height: 60px;overflow-y: auto;}.warnLevel {color: #FF0000;font-weight: bold;}}.ant-notification-notice-btn {height: 32px;width: 100%;display: flex;justify-content: center;align-items: center;opacity: 1;margin-top: 0;border-top: 1px solid #0000000F;.notification-btn-wrapper {width: 100%;display: flex;justify-content: center;align-items: center;}}.ant-notification-notice-close {top: 7px;}
}
</style>

在这里插入图片描述

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

相关文章:

  • iOS企业签名掉签,iOS企业签名掉签了怎么办?
  • H5 列表页返回后保持数据的解决方案总结(以 Vue 3 为例)
  • 【网安播报】Lazarus Group 利用开源包展开长期供应链间谍战
  • AUTOSAR进阶图解==>AUTOSAR_SRS_E2E
  • c#中switch case语句的用法
  • Spring Cloud 和服务拆分:微服务落地的第一步
  • TwinCAT3示例项目1
  • 日志管理进入「对话式」时代:日志易MCP Server落地实录
  • C# _Json数据
  • 仿艾莫迅MODBUS调试工具写一个上位机
  • 基于springboot的快递分拣管理系统
  • 【智能协同云图库】第七期:基于AI调用阿里云百炼大模型,实现AI图片编辑功能
  • 【AI 加持下的 Python 编程实战 2_12】第九章:繁琐任务的自动化(上)——自动清理电子邮件文本
  • 【Linux学习|黑马笔记|Day1】Linux初识、安装VMware Workstation、安装CentOS7、远程连接、虚拟机快照
  • Baumer工业相机堡盟工业相机如何通过YoloV8深度学习模型实现围栏羊驼的检测识别(C#代码,UI界面版)
  • 标准项目-----网页五子棋(4)-----游戏大厅+匹配+房间代码
  • AJAX快速入门 - 四个核心步骤
  • HTML无尽射击小游戏包含源码,纯HTML+CSS+JS
  • 【Flutter】内存泄漏总结
  • 【数据可视化-78】2025年上半年广东省各市GDP排名深度解析与可视化:Python + Pyecharts 深度洞察(含完整数据、代码)
  • OpenVLA: 论文阅读 -- 开源视觉-语言-行动模型
  • ZKmall开源商城微服务架构电商平台:服务注册与配置中心设计
  • Spring Boot 整合量子密钥分发(QKD)实验方案
  • Linux---make和makefile
  • 分布在背侧海马体CA1区域的位置细胞(place cells)对NLP中的深层语义分析的积极影响和启示
  • 面试题:怎么理解 OSI 参考模型(开放式系统互联参考模型) 和 TCP/IP 模型(传输控制协议 / 网际协议模型 )
  • 【vue】Vue 项目创建工具对比:vue create 与 create-vue 的核心区别
  • RAGFLOW~knowledge graph
  • k8s部署mysql
  • 【数论】P8954 「VUSC」Math Game|普及+