翻譯進行中
本頁尚未翻譯為繁體中文,以下顯示簡體中文原文。範例的預設元件文字仍使用繁體中文。
GridItem 宫格项
宫格中的图标、文字和徽标入口;可通过路由适配器跳转。
引入
uni-app 配置 easycom 后使用 <hui-grid-item>。公开类型和函数从 @nscode/handy-uni 导入;普通 Vue 3 安装 @nscode/handy-uni/web 预览插件。
示例
示例可独立运行;交互结果直接显示在页面。
vue
<template>
<view>
<hui-grid :columns="3" clickable>
<hui-grid-item icon="home" text="首页 / Home" @click="lastEvent = 'home'" />
<hui-grid-item icon="star" text="收藏 / Favorites" :badge="123" :badge-max="99" />
<hui-grid-item icon="user" text="禁用 / Disabled" disabled /> </hui-grid
><text>{{ lastEvent }}</text>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const lastEvent = ref('尚无事件 / No event')
</script>
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
text | string | — | text 属性。 |
icon | string | — | 图标名 |
iconColor | string | — | 自定义图标颜色。 |
badge | number | string | — | 图标右上角徽标(相关组件 的 value) |
dot | boolean | false | 图标右上角小红点 |
badgeMax | number | 99 | 相关组件 的 max |
to | string | — | 点击跳转,走适配器 router.push(和 相关组件 Cell 一致) |
replace | boolean | false | 用 router.replace |
disabled | boolean | false | 置灰、不发 click、不跳转 |
根节点类名和样式使用 customClass、customStyle。尺寸数字按 px,时长除明确说明外按 ms。
Events
| 事件 | 参数 |
|---|---|
click | (event: unknown) |
受控状态由父级回写更新事件后改变。多词事件使用短横线。禁用操作、取消及过期异步结果不提交成功变更。
Slots
| 插槽 | 作用域 |
|---|---|
default | — |
icon | — |
text | — |
方法
无。
类型
GridItemProps、GridItemEmits.
平台说明
基于共享平台组件实现 H5、微信小程序、App-vue 与普通 Vue 3 Web。单元测试不代替设备验收;触摸、读屏、页面失活和原生组件表现按冒烟清单逐端核对。
设备冒烟清单.