@94ai-plus/nf-alert
v1.0.0
Published
Vue 3 alert with legacy appearance, four semantic types and dual themes
Maintainers
Readme
@94ai-plus/nf-alert
HomePage
Vue 3 提示信息组件,保留旧版 success/warning/info/error、light/dark、图标、居中、辅助描述与关闭交互。
import NfAlert from '@94ai-plus/nf-alert'
import '@94ai-plus/nf-theme-chalk/nf-alert.css'
app.use(NfAlert)OEM 主题改为引入 @94ai-plus/nf-theme-oem/nf-alert.css。运行时切换时先加载两套主题 CSS,再通过 NfConfigProvider 的 theme 或 data-nf-theme 选择;只设置属性不会自动下载另一主题的样式。
<nf-alert title="导入完成" description="已处理 10 条数据" type="success" @close="onClose" />
<nf-alert title="提示">
<strong>默认插槽优先于 description。</strong>
<template #close="{ close }"><button type="button" @click="close">自定义关闭</button></template>
</nf-alert>保留 8 个属性及默认值:title/description/closeText 为空字符串,type=info、effect=light、closable=true、showIcon=true、center=false。close 事件无参数;关闭只触发一次,隐藏后改变属性不会自动重开,需通过 key/重新挂载重置。公开 close() 方法与 close 插槽的 close 回调。
title/default/close 插槽分别覆盖标题、描述和关闭区域。close 插槽完全接管关闭 UI,不受 closable 约束;默认插槽优先于 description,修复旧版同时传入时描述丢失。动态插槽切换会同步描述布局。
title/description 保留旧版 HTML 字符串能力,不进行消毒,仅可传入可信 HTML;不可信数据请用插槽文本插值。图标使用内联 SVG,不依赖 Element UI 字体或 Element Plus 样式。原生关闭按钮支持键盘、不提交表单;默认关闭标签通过 common-locale 提供八语言,业务文本不自动翻译。
全局默认配置
通过总包的 NfConfigProvider 的 nfAlert 配置项设置默认属性。支持响应式更新和嵌套继承,优先级为组件显式属性 → 最近一层配置 → 外层配置 → 组件原有默认值。undefined 继续继承,false、0 和空字符串保留;按属性合并,数组、对象和函数整体替换,不深度合并。初始化选项仍按组件原有生命周期生效,事件、插槽和原生 attributes 在组件上设置,必填业务数据仍需显式提供。详见全局配置文档。
Contributors
感谢每一位参与项目建设的贡献者!
以上为随本版本发布的贡献者统计快照,统计日期与分支见图中说明;仅统计 Git 非合并提交,头像使用姓名首字母,不是 GitLab 个人照片。
License
本项目采用 MIT License 开源许可。
Copyright (c) 2026-present Jiahe Zou, 94 Intelligent Technology Co., Ltd.
