Skip to content

Notification 消息提示 ​

为已经完成或失败的操作提供短反馈

交互示例 ​

查看用法代码
vue
<script setup lang="ts">
import { ZButton, ZNotification } from '@codex-proxy/ui'
</script>

<template>
  <ZButton @click="ZNotification.success({ message: '保存成功' })">
    显示提示
  </ZButton>
</template>

使用要点 ​

通过 ZNotification(options) 或 ZNotification.success / error / warning / info(options) 显示通知。服务自动挂载通知列表,全部通知退场后卸载容器

API ​

服务 ​

创建通知返回 { close() },可手动关闭该条通知。ZNotification.closeAll() 关闭所有通知

NotificationOptions类型默认值说明
messagestring必填通知正文
typeNotificationType'info'通知类型,快捷方法固定对应类型
titlestring类型默认标题通知标题
durationnumber3000毫秒,0 表示不自动关闭
deduplicatebooleanfalse同类型、标题、正文仍存在时复用通知

手动关闭、自动关闭和 closeAll() 都会清理对应计时器,通知列表与容器生命周期由服务内部管理