frontend/examking-app/plugins/uview-ui/components/u-grid-item/u-grid-item.vue

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<template>
	<view class="u-grid-item" :hover-class="parentData.hoverClass"
	 :hover-stay-time="200" @tap="click" :style="{
			background: bgColor,
			width: width,
		}">
		<view class="u-grid-item-box" :style="customStyle" :class="[parentData.border ? 'u-border-right u-border-bottom' : '']">
			<slot />
		</view>
	</view>
</template>

<script>
	/**
	 * gridItem 提示
	 * @description 宫格组件一般用于同时展示多个同类项目的场景,可以给宫格的项目设置徽标组件(badge),或者图标等,也可以扩展为左右滑动的轮播形式。搭配u-grid使用
	 * @tutorial https://www.uviewui.com/components/grid.html
	 * @property {String} bg-color 宫格的背景颜色(默认#ffffff)
	 * @property {String Number} index 点击宫格时,返回的值
	 * @property {Object} custom-style 自定义样式,对象形式
	 * @event {Function} click 点击宫格触发
	 * @example <u-grid-item></u-grid-item>
	 */
	export default {
		name: "u-grid-item",
		props: {
			// 背景颜色
			bgColor: {
				type: String,
				default: '#ffffff'
			},
			// 点击时返回的index
			index: {
				type: [Number, String],
				default: ''
			},
			// 自定义样式,对象形式
			customStyle: {
				type: Object,
				default() {
					return {
						padding: '30rpx 0'
					}
				}
			}
		},
		data() {
			return {
				parentData: {
					hoverClass: '', // 按下去的时候,是否显示背景灰色
					col: 3, // 父组件划分的宫格数
					border: true, // 是否显示边框,根据父组件决定
				}
			};
		},
		created() {
			// 父组件的实例
			this.updateParentData();
			// this.parent在updateParentData()中定义
			this.parent.children.push(this);
后面还有 66 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。