Vant NoticeBar 通知欄

2022-05-31 13:35 更新

引入

import Vue from 'vue';
import { NoticeBar } from 'vant';

Vue.use(NoticeBar);

代碼演示

基礎用法

<van-notice-bar text="通知內(nèi)容" left-icon="volume-o" />

禁用滾動

文字內(nèi)容多于一行時,可通過scrollable參數(shù)控制是否開啟滾動

<van-notice-bar :scrollable="false">
  通知內(nèi)容
</van-notice-bar>

多行展示

禁用滾動時,可以設置wrapable來開啟多行展示

<van-notice-bar wrapable :scrollable="false">
  通知內(nèi)容
</van-notice-bar>

通知欄模式

默認模式為空,支持closeable和link兩種模式

<!-- closeable 模式,在右側顯示關閉按鈕 -->
<van-notice-bar mode="closeable">
  通知內(nèi)容
</van-notice-bar>

<!-- link 模式,在右側顯示鏈接箭頭 -->
<van-notice-bar mode="link">
  通知內(nèi)容
</van-notice-bar>

自定義樣式

<van-notice-bar
  color="#1989fa"
  background="#ecf9ff"
  left-icon="info-o"
>
  通知內(nèi)容
</van-notice-bar>

API

Props

參數(shù)說明類型默認值
mode通知欄模式,可選值為 closeable linkstring''
text通知文本內(nèi)容string''
color文本顏色string#f60
background滾動條背景string#fff7cc
left-icon左側 圖標名稱 或圖片鏈接string-
delay動畫延遲時間 (s)number | string1
speed滾動速率 (px/s)number | string50
scrollable是否在長度溢出時滾動播放booleantrue
wrapable是否開啟文本換行,只在禁用滾動時生效booleanfalse

Events

事件名說明回調(diào)參數(shù)
click點擊通知欄時觸發(fā)event: Event
close關閉通知欄時觸發(fā)event: Event

Slots

名稱內(nèi)容
default通知文本內(nèi)容
left-icon自定義左側圖標
right-icon自定義右側圖標


實例演示

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號