Skip to content
在新窗口打开实时预览

Cell 单元格 ​

Cell 组件由 CellItem 和 CellGroup 组成:前者用于展示单条信息或入口,后者负责将多条内容组织为带标题和外边框的分组。推荐两者搭配使用;CellItem 也可以独立使用。

平台兼容性 ​

H5App微信小程序支付宝小程序
√√√√

基础用法 ​

vue
<snake-cell-group title="个人中心">
  <snake-cell-item icon="phone" title="手机号码" value="138****8000" />
  <snake-cell-item title="地址管理" value="收货地址" />
</snake-cell-group>

自定义内容与交互 ​

title、value、label 为空时可使用同名插槽;点击回调携带 index,便于识别条目。

vue
<snake-cell-group title="设置喜好">
  <snake-cell-item :arrow="false" index="1" @click="handleClick">
    <template #title>
      <text>自定义标题</text>
    </template>
    <template #right-icon>
      <text>自定义右侧内容</text>
    </template>
  </snake-cell-item>
</snake-cell-group>

分组标题与边框 ​

CellGroup 的 title 用于展示分组标题,border 控制分组内容上下边框。它可以包裹 CellItem,也可包裹其他任意内容。

vue
<snake-cell-group title="设置喜好" :border="false">
  <snake-cell-item title="消息通知" />
</snake-cell-group>

作为页面入口 ​

将跳转逻辑放在 click 中,使用 index 区分条目;纯展示项关闭箭头并避免绑定点击。

vue
<snake-cell-group title="账户">
  <snake-cell-item title="收货地址" index="address" @click="openPage" />
  <snake-cell-item title="会员等级" value="黄金会员" :arrow="false" />
</snake-cell-group>

API ​

Props ​

CellGroup Props ​

参数说明类型默认值
title分组标题string''
border是否显示分组上下边框booleantrue
titleStyle分组标题样式object | array{}
customClass / customStyle自定义类名和样式string | object | array''

CellItem Props ​

参数说明类型默认值
icon左侧图标名称或图片地址string''
title / value / label标题、右侧内容、标题下方描述string | number''
borderBottom是否显示下边框booleantrue
borderTop是否显示上边框booleanfalse
hoverClass点击反馈类名stringsnake-cell-item--hover
arrow是否显示右侧箭头booleantrue
arrowDirection右侧箭头方向right | up | downright
center内容是否垂直居中booleanfalse
required是否显示左侧必填星号booleanfalse
titleWidth标题宽度,数值按 rpx 处理number | string''
titleStyle / valueStyle / labelStyle标题、内容、描述样式object | array{}
bgColor背景颜色stringtransparent
indexclick 回调中标识条目的值string | number''
useLabelSlot是否使用 label 插槽booleanfalse
iconSize左侧图标大小,数值按 rpx 处理number | string34
iconStyle左侧图标样式object | array{}
customClass / customStyle自定义类名和样式string | object | array''

Slots ​

CellGroup Slots ​

名称说明
default分组内容

CellItem Slots ​

名称说明
default右侧内容(value 为空时启用)
icon左侧图标
title左侧标题(title 为空时启用)
label标题下方描述
right-icon右侧自定义内容

Events ​

事件名触发时机参数
click点击 CellItem 时触发index

主题变量 ​

变量名说明
--snake-color-text-secondaryCellItem 标题默认颜色
--snake-color-text-mutedCellItem 内容、描述、图标及 CellGroup 标题颜色
--snake-color-surfaceCellGroup 内容背景色
--snake-color-border条目和分组边框颜色
--snake-color-error必填标记颜色
--snake-color-surface-muted点击反馈背景色

为 uni-app 商城与 CMS 场景设计