01
实心
<cu-tag text="info" type="info" /> <cu-tag text="success" type="success" /> <cu-tag text="primary" type="primary" /> <cu-tag text="error" type="error" /> <cu-tag text="warning" type="warning" />
标签用简短文字标记分类、状态或属性,可带图标与关闭按钮。
整目录放进工程即用: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-tag /> # 4 单个组件也可以显式引入(可选,不用 easycom 时) import CuTag from '@/uni_modules/colorui-x/components/cu-tag/cu-tag.uvue'
组件样式自包含(只依赖包内 token.scss),主题层是给页面工具类用的,不参与组件注册。两种安装方式见 快速上手。
| Android | iOS | HarmonyOS | Web(H5) | 微信小程序 | 支付宝小程序 |
|---|---|---|---|---|---|
| — | — | — | √ | — | — |
Android 列取自本仓真机逐屏判定(√ 已验 / — 待复核 / × 已登记缺陷,本件当前为「待复核」)。
Web 列只表示已编出可运行的预览产物,非真机渲染。
其余三端没有任何实测证据,不作支持承诺。
<cu-tag text="info" type="info" /> <cu-tag text="success" type="success" /> <cu-tag text="primary" type="primary" /> <cu-tag text="error" type="error" /> <cu-tag text="warning" type="warning" />
<cu-tag text="info" type="info" :plain="true" /> <cu-tag text="success" type="success" :plain="true" /> <cu-tag text="primary" type="primary" :plain="true" /> <cu-tag text="error" type="error" :plain="true" /> <cu-tag text="warning" type="warning" :plain="true" />
<cu-tag text="info" type="info" :plain="true" :plainFill="true" /> <cu-tag text="success" type="success" :plain="true" :plainFill="true" /> <cu-tag text="primary" type="primary" :plain="true" :plainFill="true" /> <cu-tag text="error" type="error" :plain="true" :plainFill="true" /> <cu-tag text="warning" type="warning" :plain="true" :plainFill="true" />
<cu-tag text="large" size="large" type="primary" /> <cu-tag text="medium" size="medium" type="primary" /> <cu-tag text="mini" size="mini" type="primary" />
<cu-tag text="square" shape="square" type="success" /> <cu-tag text="circle" shape="circle" type="success" />
<cu-tag text="closable" type="error" :closable="true" name="t-closable" @close="onClose" /> <cu-tag text="自定义 closeColor" type="primary" :closable="true" closeColor="#1d7d32" />
<cu-tag text="bgColor" bgColor="#f37b1d" /> <cu-tag text="color+border" color="#ffffff" bgColor="#39b54a" borderColor="#1d7d32" />
<cu-tag text="带 icon" type="primary" icon="cuIcon-edit" />
<cu-tag text="disabled" type="warning" :disabled="true" /> <cu-tag text="不该出现" type="error" :show="false" />
<cu-tag text="type=green" type="green" /> <cu-tag text="默认(不传 type)" />
<cu-tag text="点我" type="success" name="tag-click" @click="onTagClick" /> <cu-tag text="disabled 也发" type="warning" :disabled="true" name="tag-disabled" @click="onTagClick" /> <cu-tag text="× 只发 close" type="primary" :closable="true" name="tag-both" @click="onTagClick" @close="onCloseBoth" />
这一节的交互由演示页脚本驱动,效果见右侧实时预览。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| 外观与状态 | |||
| show | 是否显示 | Boolean | true |
| type | info / success / primary / error / warning 五档配色 | String | 'primary' |
| size | large / medium / mini 三档 | String | 'medium' |
| shape | square / circle | String | 'square' |
| plain | 镂空档:只描边,文字取主题色 | Boolean | false |
| plainFill | 镂空再填浅色底;只在 plain 为真时生效 | Boolean | false |
| 颜色 | |||
| bgColor | 自定义底色 | String | '' |
| color | 自定义文字色 | String | '' |
| borderColor | 自定义描边色 | String | '' |
| 内容 | |||
| text | 标签文字 | String | '' |
| icon | 左侧图标名,取 cu-icon 白名单 | String | '' |
| 关闭 | |||
| closable | 显示关闭按钮 | Boolean | false |
| closeColor | 关闭按钮的背景色 | String | '#C6C7CB' |
| name | 点击与关闭事件载荷里的标识 | String | '' |
| 交互与样式 | |||
| customStyle | 根节点内联样式 | Object | (): UTSJSONObject => ({}) |
| customClass | 追加到根节点的类名 | String | '' |
| 声明保留但不被消费 | |||
| disabled | 禁用档;本仓未消费,传了不生效 | Boolean | false |
| url | 不产生跳转,请在 @click 里自行跳转 | String | '' |
| linkType | 不产生跳转,同上 | String | 'navigateTo' |
| 事件 | 说明 | 类型 | 默认值 | 平台差异说明 |
|---|---|---|---|---|
| @click | 点击标签时触发,回传 name | Handler | - | 各端一致 |
| @close | 点击关闭按钮时触发,回传 name | Handler | - | 各端一致 |
| slot | 说明 |
|---|---|
| icon | 自定义左侧图标区;不填时按 icon 属性渲染 |
关闭是受控的 :点关闭只派发 close,标签不会自己消失;由外层改 show 收起。