组件 / 布局 / cu-cell 单元格

cu-cell

单元格用于列表中的单行信息,组合标题、描述、右侧内容与箭头,可点击并跳转。

01 / Install

引入组件

整目录放进工程即用:easycom 按标签逐个解析,页面写哪个组件就只编译哪个,不写 import,也没有全局注册这一步;单个组件也可以显式引入(第 4 步,可选);主题层在 App.uvue 引入一次即可。

install
# 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-cell />

# 4  单个组件也可以显式引入(可选,不用 easycom 时)
import CuCell from '@/uni_modules/colorui-x/components/cu-cell/cu-cell.uvue'

组件样式自包含(只依赖包内 token.scss),主题层是给页面工具类用的,不参与组件注册。两种安装方式见 快速上手。

02 / Platform

平台支持

AndroidiOSHarmonyOSWeb(H5)微信小程序支付宝小程序
— — — √ — —

Android 列取自本仓真机逐屏判定(√ 已验 / — 待复核 / × 已登记缺陷,本件当前为「待复核」)。

Web 列只表示已编出可运行的预览产物,非真机渲染。

其余三端没有任何实测证据,不作支持承诺。

03 / Demo

代码演示

01

完整用法

左标题右值,可跳转可点击的列表行

uvue
<cu-cell-group>
  <cu-cell title="只有 title" />
  <cu-cell title="title + value" value="右侧值" />
  <cu-cell title="title + label + value" label="label 副标题在 title 下方" value="右侧值" />
  <cu-cell title="value 较长" value="右侧值较长时的表现" />
  <cu-cell title="value 极端长(负向对照)" value="这里是很长的一段右侧文本用来观察 value 区的换行与对齐表现" />
</cu-cell-group>
<cu-cell-group>
  <cu-cell icon="cuIcon-homefill" title="左图标 cuIcon-homefill" />
  <cu-cell icon="cuIcon-phone" title="左图标 cuIcon-phone" value="138****8888" />
</cu-cell-group>
<cu-cell-group>
  <cu-cell title="isLink=true(默认右图标 cuIcon-right)" :isLink="true" />
  <cu-cell title="rightIcon 换成本仓合法名" :isLink="true" rightIcon="cuIcon-rounddown" />
  <cu-cell title="arrowDirection=up" :isLink="true" arrowDirection="up" />
  <cu-cell title="arrowDirection=down" :isLink="true" arrowDirection="down" />
  <cu-cell title="arrowDirection=left(参考实现无样式)" :isLink="true" arrowDirection="left" />
  <cu-cell title="isLink=false 时 rightIcon 不渲染" rightIcon="cuIcon-warnfill" />
</cu-cell-group>
<cu-cell-group>
  <cu-cell title="center=false(默认,上下撑满)" label="带 label 时顶部对齐" value="值" />
  <cu-cell title="center=true" label="带 label 时垂直居中" value="值" :center="true" />
  <cu-cell title="disabled=true" label="不 emit、不跳转,三段文字变灰" value="值" :disabled="true" />
  <cu-cell title="border=false(无下分割线)" :border="false" />
  <cu-cell title="size 默认" value="值" />
  <cu-cell title="size=large(唯一生效值)" value="值" size="large" />
  <cu-cell title="size=small(非 large 等同默认)" value="值" size="small" />
</cu-cell-group>
<cu-cell-group>
  <cu-cell title="required=true ⇒ 不出现星号" :required="true" value="参考实现声明但模板零消费" />
  <cu-cell title="clickable=true ⇒ 与不传无差别" :clickable="true" value="@tap 无条件绑在根节点" />
  <cu-cell title="iconStyle / rightIconStyle 不消费" :isLink="true" :iconStyle="styleDemo" :rightIconStyle="styleDemo" value="cu-icon 契约无对应入口" />
  <cu-cell title="stop=true 不绑 .stop" :stop="true" value="蒸汽模式事件类型未实测" />
  <cu-cell title="titleStyle 是唯一消费的对象 prop" :titleStyle="styleDemo" value="左侧内边距 40px" />
</cu-cell-group>
<cu-cell-group>
  <cu-cell title="navigateTo → cu-icon demo 页" :isLink="true" url="/pages/base/cu-icon" />
  <cu-cell title="redirectTo → cu-tag 页(本页被替换)" :isLink="true" url="/pages/base/cu-tag" linkType="redirectTo" />
  <cu-cell title="非法 linkType(四分支外,不跳转)" :isLink="true" url="/pages/base/cu-button" linkType="pushWindow" />
</cu-cell-group>
<cu-cell-group>
  <cu-cell title="customStyle 直接落到根节点" :customStyle="styleDemo" />
  <cu-cell title="customClass 作为根节点唯一动态类" customClass="custom-class" />
</cu-cell-group>
<cu-cell-group>
  <cu-cell>
    <template #icon>
      <text>
        槽 icon
      </text>
    </template>
    <template #title>
      <text>
        槽 title(覆盖 title prop)
      </text>
    </template>
    <template #label>
      <text>
        槽 label
      </text>
    </template>
    <template #value>
      <text>
        槽 value
      </text>
    </template>
    <template #right-icon>
      <text>
        槽 right-icon
      </text>
    </template>
  </cu-cell>
</cu-cell-group>
02

文本

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

03

图标

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

04

右箭头

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

05

对齐 / 描边

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

06

未消费项

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

07

点击

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

08

跳转

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

09

自定义样式

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

10

插槽

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

11

取值与事件

这一节的交互由演示页脚本驱动,效果见右侧实时预览。

04 / Props · Events · Slots

全量 API

props

参数说明类型默认值
内容与展示
title主标题文字,占左侧首行String''
label描述文字,排在标题下方一行String''
value右侧内容文字,右对齐String''
icon左侧图标名,取图标白名单;为空时不渲染图标位String''
右侧与链接
isLink是否显示右侧箭头,默认不显示Booleanfalse
rightIcon右侧箭头图标名,默认 cuIcon-right;仅 isLink 为真时渲染String'cuIcon-right'
arrowDirection箭头朝向,up / down 带旋转样式,其余取值保持水平向右String''
url点击后跳转的页面地址,为空不跳转String''
linkType跳转方式,navigateTo / redirectTo / switchTab / reLaunch 四档;四档之外不跳转String'navigateTo'
状态与尺寸
disabled禁用档,不触发点击也不跳转,三段文字转灰Booleanfalse
border是否显示底部分割线,默认显示Booleantrue
center标题区是否垂直居中,默认顶部对齐Booleanfalse
size尺寸档,large 放大内距与字号;其它取值等同默认String''
交互与样式
clickable标记为可点击项;按下态由它或 isLink 任一为真触发Booleanfalse
name点击载荷 { name } 的取值,默认空串String''
titleStyle标题文字的内联样式对象Object(): UTSJSONObject => ({})
customStyle根节点内联样式Object(): UTSJSONObject => ({})
customClass追加到根节点的类名String''
声明保留但不被消费
required必填星号开关;本仓模板无星号节点,传参不生效Booleanfalse
iconStyle左侧图标的样式透传;图标只认名称、尺寸、颜色三档,传参不生效Object(): UTSJSONObject => ({})
rightIconStyle右侧箭头的样式透传;同上,传参不生效Object(): UTSJSONObject => ({})
stop点击阻断冒泡开关;本仓未绑冒泡阻断,传参不生效Booleantrue

events

事件说明类型默认值平台差异说明
@click点击单元格时触发(禁用档不触发),回传 UTSJSONObject 载荷 { name }Handler-各端一致

slots

slot说明
icon左侧图标位;不填时按 icon 渲染图标,该值为空则整块不出现
title标题区内容;不填时渲染 title,为空不占位
label标题下方的描述行;不填时渲染 label
value右侧内容区;不填时渲染 value
right-icon右侧箭头位,仅 isLink 为真时出现;不填时渲染 rightIcon 图标
05 / Notes

注意事项

点击不看开关 :clickable 只决定按下态,不影响点击是否触发:只传 url 也能跳转,但没有按下反馈,容易以为没点中。