Skip to content

NoticeBar 通告栏

介绍

用于循环展示通知、公告等重要信息,支持滚动、关闭与链接样式。

基础用法

通过 text 设置通告内容,默认 warning 类型;默认 mode="auto",文本溢出时自动滚动。

html
<vd-notice-bar text="这是一条通告信息,用于展示重要通知。" />

通告类型

通过 type 设置类型,可选值为 default primary success warning danger

html
<vd-notice-bar type="primary" text="主要类型通告" />
<vd-notice-bar type="success" text="成功类型通告" />

展示模式

通过 mode 设置文本展示方式:

说明
auto溢出时自动滚动(默认)
scroll强制滚动
ellipsis单行省略
wrap多行换行
html
<vd-notice-bar mode="scroll" text="技术是开发它的人的共同灵魂。" />
<vd-notice-bar mode="ellipsis" text="技术是开发它的人的共同灵魂。" />
<vd-notice-bar mode="wrap" text="技术是开发它的人的共同灵魂。" />

可关闭

通过 closeable 显示关闭按钮,配合 showclick-close 控制显隐。

html
<vd-notice-bar
  :show="show"
  closeable
  text="这条通告可以关闭"
  @click-close="show = false"
/>

链接样式

通过 is-link 显示右侧箭头并开启点击反馈,监听 click 处理跳转。也可单独使用 clickable 仅开启点击反馈。

html
<vd-notice-bar is-link text="点击查看详情" @click="onClick" />

自定义图标

通过 left-iconright-icon 自定义左右图标,与 Cell 用法一致。

html
<vd-notice-bar
  left-icon="tip-fill"
  right-icon="arrow-right"
  clickable
  text="自定义左右图标"
/>

自定义颜色

通过 colorbackground 自定义外观;left-icon 传空字符串可隐藏左侧图标。

html
<vd-notice-bar
  color="#1989fa"
  background="#ecf9ff"
  left-icon="tip-fill"
  text="自定义文字颜色与背景色"
/>

<vd-notice-bar left-icon="" text="不展示左侧图标的通告栏" />

API

Props

参数说明类型默认值
show是否展示booleantrue
text通告文本,可被默认插槽覆盖string-
type类型,可选值为 default primary success warning dangerNoticeBarType'warning'
color文本颜色,优先级高于 typestring-
background背景色,优先级高于 typestring-
left-icon左侧图标,传空字符串隐藏IconName'notify'
right-icon右侧图标IconName-
is-link是否展示右侧箭头并开启点击反馈booleanfalse
clickable是否开启点击反馈booleanfalse
mode展示模式,可选值为 auto scroll ellipsis wrapNoticeBarMode'auto'
speed滚动速率,单位 px/s;仅 auto / scroll 时生效string | number60
delay动画延迟,单位 ms;仅 auto / scroll 时生效string | number1000
closeable是否显示关闭按钮booleanfalse
transition关闭动画名称TransitionName'collapse-fade'
transition-duration关闭动画时长number | object300
transition-immediate初始化展示时是否触发动画booleantrue

代替原始 Props

参数说明类型默认值
custom-id根节点 idstring-
custom-class根节点类名ClassValue-
custom-style根节点样式StyleValue-

Events

事件名说明回调参数
click点击通告栏时触发MouseEvent
click-close点击关闭按钮时触发MouseEvent
open打开时触发-
opened打开完成时触发-
close关闭时触发-
closed关闭完成时触发-
replay滚动动画完成一轮时触发-

Slots

名称说明
default自定义通告内容
left自定义左侧内容
right自定义右侧内容
close自定义关闭按钮

类型定义

组件导出以下类型定义:

ts
import type { NoticeBarType, NoticeBarMode, NoticeBarThemeVars } from 'vital-design';

赣ICP备2025061025号-1