Cell 单元格
组织标题、说明、值和可点击入口。
引入
uni-app 配置 easycom 后使用 <hui-cell>;公开类型从 @nscode/handy-uni 导入。普通 Vue 3 项目安装 @nscode/handy-uni/web 预览版插件后使用同名组件。
示例
操作控件后,页面直接显示当前值和事件结果。
vue
<template>
<view>
<hui-cell
title="通知 / Notifications"
label="点击记录事件 / Tap to record"
value="已开启 / On"
icon="bell"
is-link
clickable
@click="event0"
/>
<hui-cell-group title="账户 / Account" inset
><hui-cell title="名称 / Name" value="Guest" /><hui-cell title="自定义 / Custom"
><template #value><hui-tag type="success">已认证 / Verified</hui-tag></template
><template #extra><text>额外内容 / Extra</text></template></hui-cell
></hui-cell-group
>
<text>{{ lastEvent }}</text>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const lastEvent = ref('尚无事件')
const describe = (value: unknown) => {
try {
return JSON.stringify(value) ?? String(value)
} catch {
return String(value)
}
}
const event0 = (arg0: unknown) => {
lastEvent.value = 'click' + ': ' + [describe(arg0)].join(', ')
}
</script>
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
title | string | — | 分组标题 |
label | string | — | 标题下的说明 |
value | string | number | — | 右侧内容 |
icon | string | — | 左侧图标 |
isLink | boolean | false | 显示右箭头,有点击反馈 |
arrowDirection | CellArrowDirection | 'right' | 箭头朝向。 |
clickable | boolean | false | 不带箭头但有点击反馈 |
required | boolean | false | 标题前加星号(FormItem 复用) |
center | boolean | false | 内容垂直居中 |
size | "large" | "default" | — | 组件尺寸;未传时沿配置继承。 |
border | boolean | undefined | 下分隔线,未传时显示;CellGroup 裁掉最后一条 |
to | string | — | 点击跳转地址,走适配器 router.push(总体设计 2.3) |
replace | boolean | false | 用 router.replace |
根节点属性见通用属性。布尔默认值为 undefined 时支持继承;显式 false 会覆盖继承值。其他布尔值按表中默认值处理。
Events
| 事件 | 参数 | 说明 |
|---|---|---|
click | (event: unknown) | 点击;有 to 时先发事件再跳转 |
Slots
| 插槽 | 参数 | 说明 |
|---|---|---|
icon | — | 自定义 icon 区域,覆盖默认内容。 |
title | — | 自定义 title 区域,覆盖默认内容。 |
label | — | 自定义 label 区域,覆盖默认内容。 |
value | — | 自定义 value 区域,覆盖默认内容。 |
default | — | 主体内容。 |
right-icon | — | 自定义 right-icon 区域,覆盖默认内容。 |
extra | — | 自定义 extra 区域,覆盖默认内容。 |
方法
无。
类型
CellProps、CellArrowDirection、CellEmits 可从 @nscode/handy-uni 导入。
ts
export type CellArrowDirection = 'right' | 'down' | 'up'
平台说明
| 行为 | uni-app H5 | 微信小程序 | App-vue | 普通 Vue 3 Web(预览) |
|---|---|---|---|---|
| 基本交互 | 已实现,待设备复核 | 已实现,待设备复核 | 已实现,待设备复核 | 由 Web 平台适配层实现 |
设备操作见冒烟清单。真实设备读数单独记录,单元测试通过不代表真机验收。