Grid宫格
引入
在app.json或index.json中引入组件,默认为ES6版本
"usingComponents": {
"vtu-grids": "/miniprogram_npm/vtuweapp/grid/grids/vtu-grids",
"vtu-grid": "/miniprogram_npm/vtuweapp/grid/grid/vtu-grid"
}
代码演示
自定义颜色
<vtu-grids col="4">
<vtu-grid label="图片" icon="iconfont icon-tupian1" icon-color="red" bind:click="click" data-label="aa" ></vtu-grid>
<vtu-grid label="清除" icon="iconfont icon-qingkong" icon-color="orange" bind:click="click" data-label="bb" ></vtu-grid>
<vtu-grid label="收藏" icon="iconfont icon-xihuanfill" icon-color="skyblue" bind:click="click" data-label="cc" ></vtu-grid>
<vtu-grid label="上传" icon="iconfont icon-shangchuan" icon-color="blue" bind:click="click" data-label="dd" ></vtu-grid>
<vtu-grid label="图片" icon="iconfont icon-tupian1" icon-color="#7e35bd" bind:click="click" data-label="ee" ></vtu-grid>
<vtu-grid label="清除" icon="iconfont icon-sousuo" icon-color="#9075fc" bind:click="click" data-label="gg" ></vtu-grid>
<vtu-grid label="收藏" icon="iconfont icon-biaoxingfill" icon-color="#1abf28" bind:click="click" data-label="er" ></vtu-grid>
<vtu-grid label="上传" icon="iconfont icon-yuanxingxuanzhongfill" icon-color="#fc973d" bind:click="click" data-label="sd" ></vtu-grid>
</vtu-grids>
基础用法
<vtu-grids col="5" border icon-color="orange" item-class="itemClass">
<vtu-grid label="图片" icon="iconfont icon-tupian1" badge_value="15"></vtu-grid>
<vtu-grid label="清除" icon="iconfont icon-qingkong"></vtu-grid>
<vtu-grid label="收藏" icon="iconfont icon-xihuanfill" badge_value="95" badge_max="50"></vtu-grid>
<vtu-grid label="上传" icon="iconfont icon-shangchuan"></vtu-grid>
<vtu-grid label="图片" icon="iconfont icon-tupian1"></vtu-grid>
<vtu-grid label="清除" icon="iconfont icon-sousuo"></vtu-grid>
<vtu-grid label="收藏" icon="iconfont icon-biaoxingfill" badge_is-dot></vtu-grid>
<vtu-grid label="上传" icon="iconfont icon-yuanxingxuanzhongfill"></vtu-grid>
<vtu-grid label="图片" icon="iconfont icon-tupian1"></vtu-grid>
<vtu-grid label="清除" icon="iconfont icon-sousuo"></vtu-grid>
</vtu-grids>
自定义大小
<vtu-grids col="3" icon-color="red" >
<vtu-grid label="图片" icon="iconfont icon-tupian1" icon-size="30px"></vtu-grid>
<vtu-grid label="清除" icon="iconfont icon-qingkong" icon-size="30px"></vtu-grid>
<vtu-grid label="收藏" icon="iconfont icon-xihuanfill" icon-size="30px"></vtu-grid>
<vtu-grid label="上传" icon="iconfont icon-shangchuan" icon-size="30px"></vtu-grid>
<vtu-grid label="禁用" icon="iconfont icon-yemian-copy-copy" icon-size="30px" disabled bind:click="click" data-label="sd"></vtu-grid>
<vtu-grid label="清除" icon="iconfont icon-sousuo" icon-size="30px"></vtu-grid>
</vtu-grids>
自定义图片
<vtu-grids col="3">
<vtu-grid label="图片" img-src="https://activity.vtuzx.com/doc/vtuUI/weapp/avatar/1.png"></vtu-grid>
<vtu-grid label="图片" img-src="https://activity.vtuzx.com/doc/vtuUI/weapp/avatar/2.png"></vtu-grid>
<vtu-grid label="图片" img-src="https://activity.vtuzx.com/doc/vtuUI/weapp/avatar/3.png"></vtu-grid>
</vtu-grids>
自定义图片大小
<vtu-grids col="4" img-width="30px">
<vtu-grid label="图片" img-src="https://activity.vtuzx.com/doc/vtuUI/weapp/avatar/1.png"></vtu-grid>
<vtu-grid label="图片" img-src="https://activity.vtuzx.com/doc/vtuUI/weapp/avatar/2.png"></vtu-grid>
<vtu-grid label="图片" img-src="https://activity.vtuzx.com/doc/vtuUI/weapp/avatar/3.png"></vtu-grid>
<vtu-grid label="图片" img-src="https://activity.vtuzx.com/doc/vtuUI/weapp/avatar/4.png"></vtu-grid>
</vtu-grids>
组件参数
Grids Props
参数 | 说明 | 类型 | 默认值 | 必填 |
---|
col | 列数 | Number | 3 | 否 |
border | 显示边框 | Boolean | - | 否 |
icon-color | 图标颜色 | String | - | 否 |
icon-size | 图标大小 | String | - | 否 |
font-color | 文本颜色 | Array | - | 否 |
font-size | 字体大小 | String | - | 否 |
img-mode | 图片裁剪、缩放的模式 | String | aspectFill | 否 |
img-width | 图片宽度 | String | - | 否 |
img-height | 图片高度 | String | - | 否 |
Grid Props
参数 | 说明 | 类型 | 默认值 | 必填 |
---|
label | 文本值 | String | - | 否 |
icon-color | 图标颜色 | String | - | 否 |
icon-size | 图标大小 | String | - | 否 |
font-color | 字体颜色 | String | - | 否 |
font-size | 字体大小 | String | - | 否 |
img-src | 图片路径 | String | - | 否 |
img-width | 图片宽度 | String | - | 否 |
img-height | 图片高度 | String | - | 否 |
hidden | 是否隐藏 | Boolean | - | 否 |
disabled | 是否禁用 | Boolean | - | 否 |
Events
方法名 | 说明 | 参数 | 返回值 |
---|
bind:click | 点击事件 | - | 绑定的参数对象及索引 |
外部样式类
外部样式类名 | 说明 |
---|
v-class | 组件外部样式类 |