uniapp九宫格布局

首先第一步引入 组件名:uni-grid

链接:https://ext.dcloud.net.cn/plugin?name=uni-grid

代码部分

<template>
	<view class="warp">
		
	
			
			<uni-grid :column="3" :highlight="true" @change="change">
				
				<uni-grid-item v-for="(item, index) in 4" :index="index" :key="index">
					
					<view class="grid-item-box" style="background-color: #fff;">
						<uni-icons type="image" :size="30" color="#777" />
						<text class="text">文本信息</text>
					</view>
					
				</uni-grid-item>
			</uni-grid>
		
	
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				
				
			}
		},
		methods: {
			
			change(e){
				console.log(e.detail.index);
				var ind = e.detail.index;
				if(ind === 0 ){
				    uni.showToast({
				    title:"id"+ind,//提示文字
				    icon:"loading",//提示图标
				    mask:true,//开启后页面不能点击
				   })
					
				}
				if(ind === 1 ){
				    uni.showToast({
				    title:"id"+ind,//提示文字
				    icon:"loading",//提示图标
				    mask:true,//开启后页面不能点击
				   })
					
				}
				
				if(ind === 2 ){
				    uni.showToast({
				    title:"id"+ind,//提示文字
				    icon:"loading",//提示图标
				    mask:true,//开启后页面不能点击
				   })
					
				}
				
				if(ind === 3 ){
				    uni.showToast({
				    title:"id"+ind,//提示文字
				    icon:"loading",//提示图标
				    mask:true,//开启后页面不能点击
				   })
					
				}
				
			}
			
			},
			
		
	}
</script>


<style lang="scss">
	.image {
		width: 50rpx;
		height: 50rpx;
	}

	.text {
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		// display: block;
		/* #endif */
	}

	.grid-dynamic-box {
		margin-bottom: 15px;
	}

	.grid-item-box {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.grid-item-box-row {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.grid-dot {
		position: absolute;
		top: 5px;
		right: 15px;
	}

	.swiper {
		height: 420px;
	}

	/* #ifdef H5 */
	@media screen and (min-width: 768px) and (max-width: 1425px) {
		.swiper {
			height: 630px;
		}
	}

	@media screen and (min-width: 1425px) {
		.swiper {
			height: 830px;
		}
	}

	/* #endif */
</style>

效果部分

在这里插入图片描述

点击事件

点击事件处理

在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值