01
默认
<cu-column-notice :text="three" @click="onClick" @close="onClose" />
纵向公告在一条窄带里轮播多条提示,可上下切换或横向滑动。
整目录放进工程即用:easycom 按标签逐个解析,页面写哪个组件就只编译哪个,不写 import,也没有全局注册这一步;单个组件也可以显式引入(第 4 步,可选);主题层在 App.uvue 引入一次即可。
# 1 整目录放进工程(easycom 自动解析) your-project/ └── uni_modules/ └── colorui-x/ # 2 App.uvue 全局引入主题层(一次) @import 'uni_modules/colorui-x/theme/base.css'; @import 'uni_modules/colorui-x/theme/layout.css'; @import 'uni_modules/colorui-x/theme/color.scss'; // 颜色工具类(.bg-* / .text-*) # 3 页面里直接用,不写 import(只编译用到的组件) <cu-column-notice /> # 4 单个组件也可以显式引入(可选,不用 easycom 时) import CuColumnNotice from '@/uni_modules/colorui-x/components/cu-column-notice/cu-column-notice.uvue'
组件样式自包含(只依赖包内 token.scss),主题层是给页面工具类用的,不参与组件注册。两种安装方式见 快速上手。
| Android | iOS | HarmonyOS | Web(H5) | 微信小程序 | 支付宝小程序 |
|---|---|---|---|---|---|
| √ | — | — | √ | — | — |
Android 列取自本仓真机逐屏判定(√ 已验 / — 待复核 / × 已登记缺陷,本件当前为「真机已验」)。
Web 列只表示已编出可运行的预览产物,非真机渲染。
其余三端没有任何实测证据,不作支持承诺。
<cu-column-notice :text="three" @click="onClick" @close="onClose" />
<cu-column-notice :text="empty" @click="onClick" /> <cu-column-notice :text="one" @click="onClick" /> <cu-column-notice :text="longOne" @click="onClick" /> <cu-column-notice :text="mixed" @click="onClick" />
<cu-column-notice :text="three" :step="false" :duration="1200" @click="onClick" /> <cu-column-notice :text="three" :step="true" :duration="1200" @click="onClick" />
<cu-column-notice :text="three" :duration="500" @click="onClick" /> <cu-column-notice :text="three" @click="onClick" /> <cu-column-notice :text="three" :duration="4000" @click="onClick" /> <cu-column-notice :text="three" :duration="0" @click="onClick" />
<cu-column-notice :text="three" :disableTouch="true" @click="onClick" /> <cu-column-notice :text="three" :disableTouch="false" @click="onClick" />
<cu-column-notice :text="three" mode="link" @click="onClick" /> <cu-column-notice :text="three" mode="closable" @click="onClick" @close="onClose" /> <cu-column-notice :text="three" mode="close" @click="onClick" />
<cu-column-notice :text="three" color="#0081ff" icon="cuIcon-warnfill" mode="link" @click="onClick" /> <cu-column-notice :text="three" color="" icon="" @click="onClick" />
<cu-column-notice :text="three" :fontSize="12" @click="onClick" /> <cu-column-notice :text="three" :fontSize="20" @click="onClick" />
<cu-column-notice :text="three" bgColor="#fadbd9" :speed="30" url="/pages/base/cu-grid" linkType="navigateTo" @click="onClick" />
<cu-column-notice :text="three" :customStyle="colStyle" customClass="custom-class" @click="onClick"> <template v-slot:icon> <text> 告 </text> </template> </cu-column-notice>
这一节的交互由演示页脚本驱动,效果见右侧实时预览。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| 内容 | |||
| text | 轮播文案数组,逐项渲染为一条;空数组时只有图标 | Array | (): Array<any> => [] |
| icon | 左侧图标名,取 cu-icon 白名单;空串不渲染左图标 | String | 'cuIcon-notificationfill' |
| 轮播与右侧动作 | |||
| mode | link 在右侧画箭头 / closable 画关闭按钮并抛 close;空串两侧都不加 | String | '' |
| step | true ⇒ 横向轮播;默认竖向逐条上移 | Boolean | false |
| duration | 每条停留时长,毫秒;直接作为轮播间隔 | Number | 1500 |
| disableTouch | true ⇒ 锁住手势,只能自动轮播 | Boolean | true |
| 文字样式 | |||
| color | 文案与图标颜色;空串走 token 默认 | String | '' |
| fontSize | 文案字号,px 契约值;运行时 ×2 换算成 rpx | Number | 14 |
| 交互与样式 | |||
| customStyle | 根节点内联样式 | Object | (): UTSJSONObject => ({}) |
| customClass | 追加到根节点的类名 | String | '' |
| 声明保留但不被消费 | |||
| bgColor | 整条底色;本仓不读取,传参不生效 | String | '' |
| speed | 滚动速率;本仓不读取,轮播节奏由 duration 决定 | Number | 80 |
| url | 不产生跳转,请在 click 里自行跳转 | String | '' |
| linkType | 不产生跳转,同上 | String | 'navigateTo' |
| 事件 | 说明 | 类型 | 默认值 | 平台差异说明 |
|---|---|---|---|---|
| @click | 点击整条通知时触发,回传当前轮播项的索引(从 0 起) | Handler | - | 各端一致 |
| @close | 点右侧关闭按钮时触发,无载荷;组件不自行隐藏,需宿主移除该条 | Handler | - | 各端一致 |
| slot | 说明 |
|---|---|
| icon | 自定义左侧图标内容;不填时按 icon 渲染,icon 为空则整块不渲染 |
长文案被裁 :轮播区高度固定为一行,每条文案超出一行就被裁掉且不加省略号;文案按一行长度裁写,别指望它换行或给省略提示。