npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@retailwe/ui-grid

v0.0.21

Published

### 介绍

Downloads

36

Readme

Grids 宫格

介绍

宫格可以在水平方向上把页面分隔成等宽度的区块,用于展示内容或进行页面导航

引入

全局引入,在 miniprogram 根目录下的app.json中配置,局部引入,在需要引入的页面或组件的index.json中配置。

// app.json 或 index.json
"usingComponents": {
  "wr-grids": "@retailwe/ui-grid/index",
    "wr-grids-item": "@retailwe/ui-grid/grid-item/index"
}

代码演示

基本用法

通过icon属性设置格子内的图标,text属性设置文字内容

<van-grid>
  <van-grid-item icon="photo-o" text="文字" />
  <van-grid-item icon="photo-o" text="文字" />
  <van-grid-item icon="photo-o" text="文字" />
  <van-grid-item icon="photo-o" text="文字" />
</van-grid>

自定义列数

默认一行展示四个格子,可以通过column-num自定义列数

<van-grid column-num="3">
  <van-grid-item icon="photo-o" text="文字" wx:for="{{ 6 }}" />
</van-grid>

自定义内容

通过插槽可以自定义格子展示的内容

<van-grid column-num="3" border="{{ false }}">
  <van-grid-item use-slot wx:for="{{ 3 }}" wx:for-item="index">
    <image
      style="width: 100%; height: 90px;"
      src="https://img.yzcdn.cn/vant/apple-{{ index + 1 }}.jpg"
    />
  </van-grid-item>
</van-grid>

正方形格子

设置square属性后,格子的高度会和宽度保持一致

<van-grid square>
  <van-grid-item icon="photo-o" text="文字" wx:for="{{ 8 }}" />
</van-grid>

格子间距

通过gutter属性设置格子之间的距离

<van-grid gutter="{{ 10 }}">
  <van-grid-item icon="photo-o" text="文字" wx:for="{{ 8 }}" />
</van-grid>

页面跳转

可以通过url属性进行页面跳转,通过link-type属性控制跳转类型

<van-grid clickable column-num="2">
  <van-grid-item
    icon="home-o"
    link-type="navigateTo"
    url="/pages/dashboard/index"
    text="Navigate 跳转"
  />
  <van-grid-item
    icon="search"
    link-type="reLaunch"
    url="/pages/dashboard/index"
    text="ReLaunch 跳转"
  />
</van-grid>

提示信息

设置dot属性后,会在图标右上角展示一个小红点。设置info属性后,会在图标右上角展示相应的徽标

<van-grid column-num="2">
  <van-grid-item icon="home-o" text="文字" dot />
  <van-grid-item icon="search" text="文字" info="99+" />
</van-grid>

API

Grid Props

| 参数 | 说明 | 类型 | 默认值 | 版本 | | ---------- | ------------------------------ | ------------------ | ------- | ---- | | column-num | 列数 | number | 4 | - | | gutter | 格子之间的间距,默认单位为px | string | number | 0 | - | | border | 是否显示边框 | boolean | true | - | | center | 是否将格子内容居中显示 | boolean | true | - | | square | 是否将格子固定为正方形 | boolean | false | - | | clickable | 是否开启格子点击反馈 | boolean | false | - | | use-slot | 是否使用自定义内容的插槽 | boolean | false |

GridItem Props

| 参数 | 说明 | 类型 | 默认值 | 版本 | | --------- | ---------------------------------------------------------- | ------------------ | ------------ | ---- | | text | 文字 | string | - | - | | icon | 图标名称或图片链接,可选值见 Icon 组件 | string | - | - | | dot | 是否显示图标右上角小红点 | boolean | false | - | | info | 图标右上角徽标的内容 | string | number | - | - | | url | 点击后跳转的链接地址 | string | - | - | | link-type | 链接跳转类型,可选值为 redirectTo switchTab reLaunch | string | navigateTo | - |

GridItem Events

| 事件名 | 说明 | 回调参数 | | ---------- | -------------- | -------- | | bind:click | 点击格子时触发 | - |

GridItem Slots

| 名称 | 说明 | | ---- | ------------------------------------------------------ | | - | 自定义宫格的所有内容,需要设置use-slot属性 | | icon | 自定义图标,如果设置了use-slot或者icon属性则不生效 | | text | 自定义文字,如果设置了use-slot或者text属性则不生效 |