
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
@ophiuchus/grid
Advanced tools
宫格可以在水平方向上把页面分隔成等宽度的区块,用于展示内容或进行页面导航。
// 方式1(推荐)
import Vue from 'vue';
import Grid from '@ophiuchus/grid';
Vue.use(Grid);
// 方式2
import Vue from 'vue';
import { Grid, GridItem } from '@ophiuchus/grid';
Vue.component(Grid.name, Grid);
Vue.component(GridItem.name, GridItem);
通过 icon 属性设置格子内的图标,text 属性设置文字内容。
<sf-grid>
<sf-grid-item icon="photograph-o" text="文字" />
<sf-grid-item icon="photograph-o" text="文字" />
<sf-grid-item icon="photograph-o" text="文字" />
<sf-grid-item icon="photograph-o" text="文字" />
</sf-grid>
默认一行展示四个格子,可以通过 column-num 自定义列数。
<sf-grid :column-num="3">
<sf-grid-item v-for="value in 6" :key="value" icon="photograph-o" text="文字" />
</sf-grid>
通过插槽可以自定义格子展示的内容。
<sf-grid :border="false" :column-num="3">
<sf-grid-item>
<sf-image src="https://img4.tuhu.org/JU_d6bTpbt6kxlAcmNKCew_w660_h520.jpeg" />
</sf-grid-item>
<sf-grid-item>
<sf-image src="https://img4.tuhu.org/4sVmt9tW6ZR89aBswsUhfA_w1600_h1295.jpeg" />
</sf-grid-item>
<sf-grid-item>
<sf-image src="https://img4.tuhu.org/D3n023kFjjgjYzz87qdh4g_w1600_h1331.jpeg" />
</sf-grid-item>
</sf-grid>
设置 square 属性后,格子的高度会和宽度保持一致。
<sf-grid square>
<sf-grid-item v-for="value in 8" :key="value" icon="photograph-o" text="文字" />
</sf-grid>
通过 gutter 属性设置格子之间的距离。
<sf-grid :gutter="10">
<sf-grid-item v-for="value in 8" :key="value" icon="photograph-o" text="文字" />
</sf-grid>
将 direction 属性设置为 horizontal,可以让宫格的内容呈横向排列。
<sf-grid direction="horizontal" :column-num="2">
<sf-grid-item icon="photograph-o" text="文字" />
<sf-grid-item icon="photograph-o" text="文字" />
<sf-grid-item icon="photograph-o" text="文字" />
</sf-grid>
通过 to 属性设置 vue-router 跳转链接,通过 url 属性设置 URL 跳转链接。
<sf-grid clickable :column-num="2">
<sf-grid-item icon="good-job-o" text="路由跳转" to="/" />
<sf-grid-item icon="search" text="URL 跳转" url="/demo.html" />
</sf-grid>
设置 dot 属性后,会在图标右上角展示一个小红点。设置 badge 属性后,会在图标右上角展示相应的徽标。
<sf-grid :column-num="2">
<sf-grid-item icon="good-job-o" text="文字" dot />
<sf-grid-item icon="search" text="文字" badge="99+" />
</sf-grid>
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| column-num | 列数 | number | string | 4 |
| icon-size | 图标大小,默认单位为px | number | string | 28px |
| gutter | 格子之间的间距,默认单位为px | number | string | 0 |
| border | 是否显示边框 | boolean | true |
| center | 是否将格子内容居中显示 | boolean | true |
| square | 是否将格子固定为正方形 | boolean | false |
| clickable | 是否开启格子点击反馈 | boolean | false |
| direction | 格子内容排列的方向,可选值为 horizontal | string | vertical |
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| text | 文字 | string | - |
| icon | 图标名称或图片链接 | string | - |
| icon-prefix | 图标类名前缀,同 Icon 组件的 class-prefix 属性 | string | sf-icon |
| dot | 是否显示图标右上角小红点 | boolean | false |
| badge | 图标右上角徽标的内容 | number | string | - |
| info | 图标右上角徽标的内容(已废弃,请使用 badge 属性) | number | string | - |
| url | 点击后跳转的链接地址 | string | - |
| to | 点击后跳转的目标路由对象,同 vue-router 的 to 属性 | string | object | - |
| replace | 是否在跳转时替换当前页面历史 | boolean | false |
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| click | 点击格子时触发 | event: Event |
| 名称 | 说明 |
|---|---|
| default | 自定义宫格的所有内容 |
| icon | 自定义图标 |
| text | 自定义文字 |
组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制。
| 名称 | 默认值 | 描述 |
|---|---|---|
| @grid-item-content-padding | @padding-md @padding-xs | - |
| @grid-item-content-background-color | @white | - |
| @grid-item-content-active-color | @active-color | - |
| @grid-item-icon-size | 28px | - |
| @grid-item-text-color | @gray-7 | - |
| @grid-item-text-font-size | @font-size-sm | - |
FAQs
### 介绍
The npm package @ophiuchus/grid receives a total of 5 weekly downloads. As such, @ophiuchus/grid popularity was classified as not popular.
We found that @ophiuchus/grid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.