默认给height:auto;就看不到图片了,要想实现自适应高度效果,首先给图片设置 mode="widthFix"

<view class="img-info">
				<image mode="widthFix" src="../../static/img/p10.jpg" />
				<image mode="widthFix" src="../../static/img/p10.jpg" />
				<image mode="widthFix" src="../../static/img/p10.jpg" />
				<image mode="widthFix" src="../../static/img/p10.jpg" />
			</view>

 样式中设置高度自适应 height:auto; 就可以了

.img-info {
	margin-top:20rpx;
	display:flex;
	flex-wrap: wrap;
	justify-content: space-around;
	image {
		width:320rpx;
		height:auto;
		margin-bottom: 20rpx;
	}
}

以上是一行两列的图片布局效果,宽度固定,高度自适应

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐