注册 X
提交 注:点击提交后系统会发送邮件到邮箱验证!(仅支持中国大陆邮箱)
我已阅读并同意 服务条款
首页 > IT技术笔记 > 查看笔记

vant-NoticeBar 通知栏

介绍

用于循环播放展示一组消息通知。

引入

        
        
      

代码演示

基础用法

通过 `text` 属性设置通知栏的内容,通过 `left-icon` 属性设置通知栏左侧的图标。

        
        
      

滚动播放

通知栏的内容长度溢出时会自动开启滚动播放,通过 `scrollable` 属性可以控制该行为。

        
        
      

多行展示

文字较长时,可以通过设置 `wrapable` 属性来开启多行展示。

        
        
      

通知栏模式

通知栏支持 `closeable` 和 `link` 两种模式。

        
        
      

自定义样式

通过 `color` 属性设置文本颜色,通过 `background` 属性设置背景色。

        
        
      

垂直滚动

搭配 NoticeBar 和 Swipe 组件可以实现垂直滚动的效果。

        
        
      

API

Props

参数说明类型默认值
mode通知栏模式,可选值为 closeable linkstring''
text通知文本内容string''
color通知文本颜色string#f60
background滚动条背景string#fff7cc
left-icon左侧[图标名称](https://youzan.github.io/vant/v2/#/zh-CN/icon)或图片链接string-
delay动画延迟时间 (s)number / string1
speed滚动速率 (px/s)number / string60
scrollable是否开启滚动播放,内容长度溢出时默认开启boolean-
wrapable是否开启文本换行,只在禁用滚动时生效booleanfalse

Events

事件名说明回调参数
click点击通知栏时触发event: Event
close关闭通知栏时触发event: Event
replay v2.6.2每当滚动栏重新开始滚动时触发-

Slots

名称内容
default通知文本内容
left-icon自定义左侧图标
right-icon自定义右侧图标

方法

通过 ref 可以获取到 NoticeBar 实例并调用实例方法,详见

组件实例方法

方法名说明参数返回值
reset v2.12.32重置通知栏到初始状态--

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考

主题定制

名称默认值描述
@notice-bar-height40px-
@notice-bar-padding0 @padding-md-
@notice-bar-wrapable-padding@padding-xs @padding-md-
@notice-bar-text-color@orange-dark-
@notice-bar-font-size@font-size-md-
@notice-bar-line-height24px-
@notice-bar-background-color@orange-light-
@notice-bar-icon-size16px-
@notice-bar-icon-min-width24px-


效果图:


 打赏        分享



评论

邮箱: 昵称: