形状
<cu-capsule leftText="720'P" rightText="普清" /> <cu-capsule leftText="1080'P" rightText="全高" shape="radius" /> <cu-capsule leftText="4K" rightText="超清" shape="round" />
胶囊条把两段短文本拼成一枚标签,左侧实底、右侧描边。
整目录放进工程即用: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-capsule /> # 4 单个组件也可以显式引入(可选,不用 easycom 时) import CuCapsule from '@/uni_modules/colorui-x/components/cu-capsule/cu-capsule.uvue'
组件样式自包含(只依赖包内 token.scss),主题层是给页面工具类用的,不参与组件注册。两种安装方式见 快速上手。
| Android | iOS | HarmonyOS | Web(H5) | 微信小程序 | 支付宝小程序 |
|---|---|---|---|---|---|
| √ | — | — | √ | — | — |
Android 列取自本仓真机逐屏判定(√ 已验 / — 待复核 / × 已登记缺陷,本件当前为「真机已验」)。
Web 列只表示已编出可运行的预览产物,非真机渲染。
其余三端没有任何实测证据,不作支持承诺。
<cu-capsule leftText="720'P" rightText="普清" /> <cu-capsule leftText="1080'P" rightText="全高" shape="radius" /> <cu-capsule leftText="4K" rightText="超清" shape="round" />
<cu-capsule leftText="热" rightText="飙升" color="#e54d42" shape="radius" /> <cu-capsule leftText="蓝" rightText="描边" color="#0081ff" shape="round" /> <cu-capsule leftText="渐变" rightText="端点" color="linear-gradient(to right, #f43f3b, #ec008c)" shape="radius" /> <cu-capsule leftText="浅底" rightText="白字对比" color="#fef2ce" shape="round" />
<cu-capsule leftText="SM" rightText="胶囊" size="sm" color="#39b54a" shape="radius" /> <cu-capsule leftText="normal" rightText="对照" size="normal" color="#39b54a" shape="radius" />
<cu-capsule leftText="" rightText="" shape="radius" /> <cu-capsule leftText="超长超长的一段左文字" rightText="超长的一段右文字" shape="round" color="#f37b1d" /> <cu-capsule leftText="shape=big" rightText="非法档" shape="big" />
<cu-capsule leftText="A" rightText="片" shape="radius" color="#1cbbb4" /> <cu-capsule leftText="B" rightText="片" shape="radius" color="#9c26b0" />
这一节的交互由演示页脚本驱动,效果见右侧实时预览。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| 内容 | |||
| leftText | 左半实心底上的文字 | String | '' |
| rightText | 右半描边区的文字 | String | '' |
| 外观 | |||
| color | 两半共用色:左半底色、右半描边与文字色;空串走默认配色 | String | '' |
| shape | square / radius / round 三档外形 | String | 'square' |
| size | normal / sm 两档字号 | String | 'normal' |
| 样式 | |||
| customStyle | 根节点内联样式 | Object | (): UTSJSONObject => ({}) |
| customClass | 追加到根节点的类名 | String | '' |
| 声明保留但不被消费 | |||
| url | 不产生跳转 | String | '' |
| linkType | 不产生跳转,同上 | String | 'navigateTo' |
本件不派发事件。
本件没有插槽。
一色管两半 :一个色值同时决定左半底色、右半描边与右半文字色,左半文字固定反白;传浅色时右半文字会淡到看不清,深浅分色只能拆成两件自己拼。
宽度随文字 :根节点按内容宽度收,不跟随列向父级拉伸;想让它铺满整行,得自己在外层包一个定宽容器,或用自定义样式补宽度。