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

相关文章:

  • 算法题——数组
  • Master Prompt:AI时代的万能协作引擎
  • html5和vue区别
  • 使用 Scikit-LLM 进行零样本和少样本分类
  • spring boot 使用mybatis简单连接数据库+连表查询
  • 向量投影计算,举例说明
  • LangChain详解
  • codex体验失败记录
  • Web3.0如何塑造互联网的未来
  • [echarts]基础地图
  • 北极圈金融科技革命:奥斯陆证券交易所的绿色跃迁之路 ——从Visma千倍增长到碳信用衍生品,解码挪威资本市场的技术重构
  • 数据结构(11)栈和队列算法题 OVA
  • 基于OpenCV的cv2.solvePnP方法实现头部姿态估计
  • AJAX快速入门 - 四个核心步骤
  • DB-GPT 0.7.3 版本更新:支持Qwen3 Embedding和Reranker模型、支持知识库自定义检索策略等
  • 从Web2.0到Web3.0:社交参与方式的重塑与延伸
  • 优化算法专栏——阅读导引
  • springboot助农平台
  • 【PHP 类常量详解:从入门到精通】
  • RK3588实现wlan直连
  • Qt 开发 IDE 插件开发指南
  • 如何在UEFI SHELL下查看UEFI Driver
  • 洛谷P4479第K大斜率
  • OSPF笔记整理
  • Transformer架构全解析:搭建AI的“神经网络大厦“
  • 开箱即用的Next.js SSR企业级开发模板
  • 【性能测试】混合业务场景TPS+内存溢出定位分析+调优和分析(详情)
  • 猫眼浏览器:简约安全的 Chrome 内核增强版浏览器
  • 【JVM篇13】:兼顾吞吐量和低停顿的G1垃圾回收器
  • UniappDay06