默认
<cu-text text="ColorUI-X 文本" />
文本按统一的字号与颜色展示一段文字,支持脱敏与链接档。
整目录放进工程即用: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-text /> # 4 单个组件也可以显式引入(可选,不用 easycom 时) import CuText from '@/uni_modules/colorui-x/components/cu-text/cu-text.uvue'
组件样式自包含(只依赖包内 token.scss),主题层是给页面工具类用的,不参与组件注册。两种安装方式见 快速上手。
| Android | iOS | HarmonyOS | Web(H5) | 微信小程序 | 支付宝小程序 |
|---|---|---|---|---|---|
| √ | — | — | √ | — | — |
Android 列取自本仓真机逐屏判定(√ 已验 / — 待复核 / × 已登记缺陷,本件当前为「真机已验」)。
Web 列只表示已编出可运行的预览产物,非真机渲染。
其余三端没有任何实测证据,不作支持承诺。
<cu-text text="ColorUI-X 文本" />
<cu-text type="primary" text="type=primary" /> <cu-text type="warning" text="type=warning" /> <cu-text type="success" text="type=success" /> <cu-text type="info" text="type=info" /> <cu-text type="error" text="type=error" /> <cu-text type="main" text="type=main" /> <cu-text type="content" text="type=content" /> <cu-text type="tips" text="type=tips" /> <cu-text type="light" text="type=light" />
<cu-text mode="text" text="mode=text" /> <cu-text mode="price" text="10000" /> <cu-text mode="phone" text="12345678901" /> <cu-text mode="name" text="张三" /> <cu-text mode="date" text="2026-10-18" /> <cu-text mode="link" href="/pages/base/cu-image" text="mode=link 委托 cu-link" />
<cu-text mode="phone" format="encrypt" text="12345678901" /> <cu-text mode="phone" format="encrypt" text="123" /> <cu-text mode="name" format="encrypt" text="张三" /> <cu-text mode="name" format="encrypt" text="欧阳修文" />
<cu-text :size="22" text="size 22 → 44rpx" /> <cu-text color="#e54d42" text="color 使用者传值(走内联,§6 第 3 条)" /> <cu-text :bold="true" text="bold 加粗" /> <cu-text align="center" text="align=center" /> <cu-text align="right" text="align=right" /> <cu-text lineHeight="60rpx" text="lineHeight=60rpx(本仓要求带单位,见组件内注释)" /> <cu-text decoration="underline" text="decoration=underline" /> <cu-text decoration="line-through" text="decoration=line-through" />
<cu-text text="这是一段用来观察换行与截断行为的超长中文文本,lines 在本仓声明未消费,所以它只会按自然换行铺开而不会出现多行省略号,这正是需要真机复核的观察点" /> <cu-text :lines="'1'" text="lines=1 已传但未消费(上一条同形)" /> <cu-text :block="true" text="block=true 未消费(参考实现落 display: block,编译器拒)" /> <cu-text wordWrap="break-word" text="wordWrap 未消费(word-wrap 属性本仓无实测依据)" /> <cu-text openType="share" text="openType 未消费(小程序 button 专属分支)" /> <cu-text text="" /> <cu-text :show="false" text="show=false,这行不应出现" />
<cu-text prefixIcon="cuIcon-pic" text="前置图标" /> <cu-text suffixIcon="cuIcon-right" text="后置图标" /> <cu-text prefixIcon="cuIcon-pic" suffixIcon="cuIcon-roundclose" text="两端图标" /> <cu-text :iconStyle="iconStyleDemo" prefixIcon="cuIcon-pic" text="iconStyle 传了但未消费" />
<cu-text :call="true" mode="phone" text="10086" /> <cu-text :margin="10" text="margin=10 → 20rpx 四向" /> <cu-text customClass="custom-class" text="customClass 追加在类串末尾" /> <cu-text :customStyle="blockStyle" text="customStyle 传对象" @click="onEcho" />
这一节的交互由演示页脚本驱动,效果见右侧实时预览。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| 内容 | |||
| text | 要显示的文字 | String | '' |
| mode | text / price / phone / name / link;link 档走链接样式 | String | '' |
| show | 是否显示 | Boolean | true |
| 外观 | |||
| type | primary / warning / success / info / error / main / content / tips / light 色档 | String | '' |
| size | 字号,px 契约值;运行时 ×2 换算成 rpx | Number | 15 |
| color | 文字颜色;指定 type 档时由色档接管 | String | '#303133' |
| bold | 加粗 | Boolean | false |
| decoration | none / underline / line-through | String | 'none' |
| lineHeight | 行高,需自带单位 | String | '' |
| align | left / center / right | String | 'left' |
| margin | 外边距,px 契约值;0 不带单位 | Number | 0 |
| 前后缀图标 | |||
| prefixIcon | 文字前的图标名,取 cu-icon 白名单 | String | '' |
| suffixIcon | 文字后的图标名 | String | '' |
| 链接与格式 | |||
| href | mode=link 时传给链接的目标地址 | String | '' |
| format | phone / name 搭配 encrypt 做脱敏 | String | '' |
| call | phone 档点击时是否直接拨号 | Boolean | false |
| 交互与样式 | |||
| customStyle | 根节点内联样式 | Object | (): UTSJSONObject => ({}) |
| customClass | 追加到根节点的类名 | String | '' |
| 声明保留但不被消费 | |||
| openType | 微信开放能力;本仓 App 端不接通 | String | '' |
| block | 块状显示;本仓 display 只支持 flex / none,传了不生效 | Boolean | false |
| lines | 多行省略行数;App 端未实测,传了不生效 | String | '' |
| iconStyle | 图标样式透传;本仓 cu-icon 只收 name / size / color,传了不生效 | Object | (): UTSJSONObject => ({ fontSize: '15px' }) |
| wordWrap | 断词规则;本仓未消费 | String | 'normal' |
| url | 不产生跳转 | String | '' |
| linkType | 不产生跳转,同上 | String | 'navigateTo' |
| 事件 | 说明 | 类型 | 默认值 | 平台差异说明 |
|---|---|---|---|---|
| @click | 点击时触发,无载荷;phone 档且 call 为真时先拨号 | Handler | - | 各端一致 |
本件没有插槽。
23 · 下划线不渲染 :decoration=underline 在 App 端不显示;需要下划线请用 mode=link。
脱敏规则 :phone 档保留前 3 位与后 4 位,name 档保留首尾字符。