更新记录
                                                                                                    
                                                    
                                                        1.0.0(2025-03-13)
                                                                                                                    
                                                                下载此版本
                                                            
                                                        
                                                    
                                                    发布初版
                                                                                                                                                
                                            
                                                                                                                                                        平台兼容性
                                                                                                                                                                                                                                                                                                                                uni-app
                                                                                                                                                                                                                                    
| Vue2 | 
Vue3 | 
Chrome | 
Safari | 
app-vue | 
app-nvue | 
Android | 
iOS | 
鸿蒙 | 
| √ | 
√ | 
√ | 
√ | 
√ | 
- | 
- | 
- | 
- | 
                                                                                                                                                            
| 微信小程序 | 
支付宝小程序 | 
抖音小程序 | 
百度小程序 | 
快手小程序 | 
京东小程序 | 
鸿蒙元服务 | 
QQ小程序 | 
飞书小程序 | 
快应用-华为 | 
快应用-联盟 | 
| √ | 
- | 
- | 
- | 
- | 
- | 
- | 
- | 
- | 
- | 
- | 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                其他
                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                            NoticeBar 滚动通知条
组件名: xt-notice-bar
安装方式
本组件符合 easycom 规范,HBuilderX 3.1.0 起,只需将本组件导入项目,在页面 template 中即可直接使用,无需在页面中 import 和注册 components
注意事项
如何阻止事件冒泡
vue2:在组件上直接使用@click.native.stop,如:<xt-icon @click.native.stop='click'></xt-icon>;
vue3:由于 vue3 没有native修饰符,所以不能直接在组件上使用.stop修饰符,只能嵌套一层view标签,在外层view上添加@click.stop阻止冒泡
基本用法
<template>
    <view class="xt">
        <view>
            <view style="font-size: 28rpx">基础用法</view>
            <xt-notice-bar :text="list"></xt-notice-bar>
        </view>
        <view>
            <view style="font-size: 28rpx">步进模式</view>
            <xt-notice-bar :text="list" step></xt-notice-bar>
        </view>
        <view>
            <view style="font-size: 28rpx">纵向滚动</view>
            <xt-notice-bar direction="column" :text="list"></xt-notice-bar>
        </view>
        <view>
            <view style="font-size: 28rpx">自定义颜色</view>
            <xt-notice-bar :text="list" color="#ff4757" bgColor="#2f3542"></xt-notice-bar>
        </view>
        <view>
            <view style="font-size: 28rpx">自定义样式</view>
            <xt-notice-bar
                :text="list"
                :customStyle="{
                    borderRadius: '10rpx',
                    padding: '20rpx',
                    backgroundColor: '#2f3542'
                }"
            ></xt-notice-bar>
        </view>
        <view>
            <view style="font-size: 28rpx">左右插槽</view>
            <xt-notice-bar :show="show" :text="list" direction="column" @click="onclick" disableTouch>
                <template #left>
                    <view @click="left">
                        <xt-icon name="xt-icon-shengyin" color="#000"></xt-icon>
                    </view>
                </template>
                <template #right>
                    <xt-icon @click="close" name="xt-icon-close" color="#000"></xt-icon>
                </template>
            </xt-notice-bar>
            <xt-button style="margin-top: 20rpx" @click="close" size="mini">开启滚动条</xt-button>
        </view>
    </view>
</template>
<script>
export default {
    data() {
        return {
            list: ['滚动通知滚动通知滚动通知滚动通知', '第二条滚动通知'],
            show: true
        };
    },
    methods: {
        onclick(e) {
            console.log(e);
        },
        left() {
            console.log('点击了左边');
        },
        close() {
            this.show = !this.show;
        }
    }
};
</script>
<style lang="scss">
.xt {
    padding: 20rpx;
    display: flex;
    flex-direction: column;
    gap: 30rpx;
}
</style>
API
| 属性 | 
类型 | 
默认值 | 
说明 | 
show | 
String | 
true | 
是否显示通知条 | 
text | 
Array | String | 
- | 
direction | 
String | 
row | 
通告滚动模式,row-横向滚动,column-竖向滚动 | 
disableTouch | 
Boolean | 
false | 
direction = column 或 步进模式时,是否禁止手动滑动 | 
step | 
Boolean | 
false | 
步进形式滚动 | 
color | 
String | 
#ffa502 | 
文字颜色 | 
bgColor | 
String | 
#FDF6EC | 
背景颜色 | 
fontSize | 
String|Number | 
28rpx | 
文字大小 | 
speed | 
String|Number | 
80 | 
水平滚动时的滚动速度,每秒滚动多少像素 | 
duration | 
String|Number | 
2000 | 
direction = column 或 步进模式时,滚动一个周期的时间ms | 
customStyle | 
Object | 
- | 
自定义样式 | 
stop | 
Boolean | 
false | 
是否阻止事件冒泡 | 
Event
| 属性 | 
类型 | 
描述 | 
默认值 | 
click | 
Function | 
点击文字事件 | 
- |