uniapp+vue开发微信小程序实现瀑布流

本文介绍了如何在uniapp中使用模板创建商品推荐列表,包括卡片样式设计,如自适应图片、列数设置、间距控制以及商品信息的展示。
摘要由CSDN通过智能技术生成

<template>
	<view class="container">
		<!-- 商品卡片 -->
		<view class="content">
			<view class="item" v-for="item in commendList" :key="item.id">
				<image class="img" :src="item.image" mode="widthFix"></image>
				<view class="name">
					{{item.name}}
				</view>
				<view class="bottom">
					<view class="price">
						¥9.9元
					</view>
					<view class="total">
						已售99件
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script setup>
//数据
const commendList = ref([]);
</script>
<style scoped lang="scss">
	.container {
		.content {
			padding: 0 3vw;
			column-count: 2;//限制两列数据
            //column-width:;//列的宽度
            //column-gap:;//列与列之间的间距
			.item {
				border: 1px solid rgba(255, 255, 255, 1);
				border-radius: 10rpx;
				width: 45vw;
				background-color: white;
				break-inside: avoid;//防止元素中断到不同列
				margin-bottom: 20rpx;
				.img {
					width: 45vw;
					max-height: 26vh;
				}

				.name {
					color: rgba(16, 16, 16, 1);
					font-size: 26rpx;
					height: 50rpx;
					line-height: 50rpx;
					padding: 0 10rpx;
				}

				.bottom {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 24rpx;
					height: 50rpx;
					line-height: 50rpx;
					padding: 0 16rpx;

					.price {
						color: rgba(16, 16, 16, 1);
					}

					.total {
						color: #9F9F9F;
					}
				}
			}
		}
	}
</style>

注:

1、uniapp没有img标签,只有image,这里需要给image标签加上mode="widthFix",图片才会高度自适应

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Angus-zoe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值