# Grid 宫格 ### 介绍 用于分隔成等宽区块进行页面导航。 ### 安装 ``` javascript import { createApp } from 'vue'; // vue import { Grid, GridItem } from '@nutui/nutui'; // taro import { Grid, GridItem } from '@nutui/nutui-taro'; const app = createApp(); app.use(Grid); app.use(GridItem); ``` ### 基础用法 ``` html ``` ### 自定义列数 ``` html ``` ### 正方形格子 ``` html ``` ### 格子间距 ``` html ``` ### 内容翻转 ``` html ``` ### 内容横向 ``` html ``` ### 图标颜色/大小 ``` html ``` ### 页面导航 ``` html ``` ### 自定义内容 ``` html ``` ### Grid Props | 参数 | 说明 | 类型 | 默认值 | |---------------|------------------------------------------|------------------------|------------| | column-num | 列数 | number \| string | `4` | | icon-size | 图标大小,如 `20px` `2em` `2rem` | number \| string | `28px` | | icon-color | 图标颜色 | string | - | | border | 是否显示边框 | boolean | `true` | | gutter | 格子之间的间距,默认单位为`px` | number \| string | `0` | | center | 是否将格子内容居中显示 | boolean | `true` | | square | 是否将格子固定为正方形 | boolean | `false` | | reverse | 内容翻转 | boolean | `false` | | direction | 格子内容排列的方向,可选值为 `horizontal` | string | `vertical` | | clickable | 是否开启格子点击反馈 | boolean | `false` | ### GridItem Props | 参数 | 说明 | 类型 | 默认值 | |----------------------|-----------------------------------------------------------------------------------------|--------------------|------------| | text | 文字 | string | - | | icon | [图标名称](#/icon) 或图片链接 | string | - | | icon-size | 图标大小,如 `20px` `2em` `2rem` | number \| string | `28px` | | icon-color | 图标颜色 | string | - | | url `小程序不支持` | 点击后跳转的链接地址 | string | - | | to `小程序不支持` | 点击后跳转的目标路由对象,同 vue-router 的 [to 属性](https://router.vuejs.org/zh/api/#to) 属性 | string \| object | - | | replace `小程序不支持` | 是否在跳转时替换当前页面历史 | boolean | `false` | ### GridItem Slots | 名称 | 说明 | |-----------------------|----------------------| | default | 自定义所有内容 | | icon | 自定义图标 | | text | 自定义文字 | ### GridItem Event | 事件名 | 说明 | 回调参数 | |-----------------------|-----------------------|-----------------------| | click | 点击格子时触发 | event: Event |