翻譯進行中
本頁尚未翻譯為繁體中文,以下顯示簡體中文原文。範例的預設元件文字仍使用繁體中文。
Grid 宫格
为宫格项提供列数、间距、边框和排列方向。
引入
uni-app 配置 easycom 后使用 <hui-grid>。公开类型和函数从 @nscode/handy-uni 导入;普通 Vue 3 安装 @nscode/handy-uni/web 预览插件。
示例
示例可独立运行;交互结果直接显示在页面。
vue
<template>
<view>
<hui-space direction="vertical" fill>
<hui-grid custom-class="hui-space__item" :columns="3" square clickable
><hui-grid-item
v-for="index in 6"
:key="index"
icon="star"
:text="'入口 / Entry ' + index"
:badge="index === 1 ? 10 : undefined"
@click="lastEvent = String(index)"
/></hui-grid>
<hui-grid
custom-class="hui-space__item"
:columns="2"
:gutter="8"
:border="false"
direction="horizontal"
><hui-grid-item icon="home" text="首页 / Home" /><hui-grid-item
icon="user"
text="用户 / User"
disabled
/></hui-grid>
<text class="hui-space__item">{{ lastEvent }}</text>
</hui-space>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const lastEvent = ref('尚无事件 / No event')
</script>
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
columns | number | 4 | 列数(和 Waterfall 一致叫 columns) |
gutter | number | 0 | 格子间距,px |
border | boolean | true | 细边框;gutter > 0 时每格四边都有框 |
square | boolean | false | 格子是正方形 |
center | boolean | true | 内容居中 |
direction | GridDirection | 'vertical' | 图标和文字上下排还是左右排 |
clickable | boolean | false | 所有格子有按下反馈 |
iconSize | number | 28 | px |
根节点类名和样式使用 customClass、customStyle。尺寸数字按 px,时长除明确说明外按 ms。
Events
无。
Slots
| 插槽 | 作用域 |
|---|---|
default | — |
方法
无。
类型
GridDirection、GridProps、GridEmits.
主题变量
--hui-grid-icon-size 控制默认图标的尺寸,优先于 iconSize;未设置时使用 iconSize,默认 28px。可通过 Grid 的 customStyle 或祖先样式统一配置。
平台说明
基于共享平台组件实现 H5、微信小程序、App-vue 与普通 Vue 3 Web。单元测试不代替设备验收;触摸、读屏、页面失活和原生组件表现按冒烟清单逐端核对。
设备冒烟清单.