GridItem
An icon, label and badge entry within a grid; optional navigation uses the router adapter.
Import
Use <hui-grid-item> after configuring uni-app easycom. Import public types and functions from @nscode/handy-uni. Ordinary Vue applications install the @nscode/handy-uni/web preview plugin.
Examples
Each example is standalone. Controls show the current value or event result on the page.
<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
| Prop | Type | Default | Details |
|---|---|---|---|
text | string | — | Text content; NoticeBar also accepts a list. |
icon | string | — | Icon registry name. |
iconColor | string | — | Explicit icon color. |
badge | number | string | — | Badge text or number. |
dot | boolean | false | Displays a dot indicator. |
badgeMax | number | 99 | Maximum badge number before excess notation. |
to | string | — | Navigation target resolved by the router adapter. |
replace | boolean | false | Replaces the current router entry instead of pushing. |
disabled | boolean | false | Disables user interaction. |
Root classes and styles use customClass and customStyle. Numbers representing dimensions use px; durations use ms unless explicitly documented.
Events
| Event | Arguments |
|---|---|
click | (event: unknown) |
Controlled state only changes when the parent accepts its update event. Events with multiple words use kebab-case. Disabled or stale asynchronous actions do not emit a successful state change.
Slots
| Slot | Scope |
|---|---|
default | — |
icon | — |
text | — |
Methods
None.
Types
GridItemProps、GridItemEmits.
Platform notes
Supports H5, WeChat mini-program, App-vue and ordinary Vue 3 Web through shared platform components. Unit tests do not replace device acceptance; verify touch, screen readers, deactivation and native rendering on each target.
Device smoke checklist.