t-notice-bar
NoticeBar 通知栏
组件介绍
通知栏组件,支持多种主题、尺寸和滚动模式,适用于在应用中展示重要通知或公告信息。
平台兼容
| Harmony | H5 | Android | iOS | 小程序 | UTS |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
基础用法
vue
<template>
<view class="notice-bar-demo">
<t-notice-bar :barList="noticeList" prefixIcon="volume-up"></t-notice-bar>
<t-notice-bar :barList="noticeList" :step="true" :vertical="true"></t-notice-bar>
<t-notice-bar :barList="noticeList" type="warning" suffixIcon="arrow-right"></t-notice-bar>
</view>
</template>
<script setup>
const noticeList = ref([
'这是第一条通知公告',
'这是第二条通知公告',
'这是第三条通知公告'
]);
</script>
<style scoped>
.notice-bar-demo {
padding: 20rpx;
}
</style>Props
| 属性名 | 类型 | 默认值 | 说明 | 可选值 |
|---|---|---|---|---|
| size | String | "medium" | 组件尺寸 | large, medium, small, mini |
| type | String | "" | 组件类型 | info, primary, error, warning, success |
| disabled | Boolean | false | 组件是否禁用 | true, false |
| hover | Boolean | false | 是否有点击效果 | true, false |
| path | String | "" | 点击组件后跳转的页面路径 | - |
| effect | String | "normal" | 组件显示主题 | normal, dark, light, plain |
| barList | Array | [] | 消息列表 | - |
| interval | Number | 100 | 滚动间隔,单位为毫秒 | - |
| duration | Number | 12000 | 滚动持续时间,单位为毫秒 | - |
| vertical | Boolean | false | 是否纵向滚动 | true, false |
| step | Boolean | false | 是否步进滚动 | true, false |
| prefixIcon | String | "" | 前置图标的名称 | - |
| prefixClass | String | "" | 前置图标的样式 | - |
| suffixIcon | String | "" | 后置图标的名称 | - |
| suffixClass | String | "" | 后置图标的样式 | - |
| speed | Number | 1 | 公告滚动速度,横向滚动时生效 | - |
Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| select | 点击公告时触发 | 当前点击公告的索引 |
| click | 点击时触发 | - |
| transitionend | 动画结束时触发 | - |
| initFinished | 组件初始化完成触发 | 组件的节点信息 |
| touchstart | 触摸开始时触发 | 触摸事件对象 |
| touchend | 触摸结束时触发 | 触摸事件对象 |
| touchmove | 触摸移动时触发 | 触摸事件对象 |
| touchcancel | 触摸取消时触发 | 触摸事件对象 |