当前位置:网站首页>uniapp微信小程序拿来即用的瀑布流布局demo2(方法二)(复制粘贴即可使用,无需做其他处理)
uniapp微信小程序拿来即用的瀑布流布局demo2(方法二)(复制粘贴即可使用,无需做其他处理)
2022-07-05 00:02:00 【我是开心呀】
效果图:
<template>
<view class="container">
<view class="left">
<view v-for="(item,index) in leftList" :key="index" class="imgBox">
<image :src="item.img" alt="" mode="widthFix"></image>
<view class="txt">{
{
item.name}}</view>
</view>
</view>
<view class="right">
<view v-for="(item,index) in rightList" :key="index" class="imgBox">
<image :src="item.img" alt="" mode="widthFix"></image>
<view class="txt">{
{
item.name}}</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
list: [{
img: "../../static/home/weixin.png",
name: '0商品的名称,可以很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长',
id: 100
}, {
img: "../../static/home/bg_yjc.png",
name: '1商品的名称,可以很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长',
id: 100
}, {
img: "../../static/home/bg.png",
name: '2商品名称会在超出N行时候不折叠',
id: 100
},
{
img: "../../static/home/bg.png",
name: '3只有二行标题时高度为39',
id: 100
}, {
img: "../../static/home/bg.png",
name: '4具体样式您可以自定义',
id: 100
}, {
img: "../../static/home/bg_yjc.png",
name: '5vue的H5页面也是如此使用',
id: 100
}, {
img: "../../static/img/shenfen1.png",
name: '6只有一行标题时',
id: 100
}, {
img: "../../static/home/bg_yjc.png",
name: '7vue的H5页面也是如此使用',
commdityPrice: 100
}, {
img: "../../static/home/bg.png",
name: '8vue的H5页面也是如此使用',
commdityPrice: 100
}, {
img: "../../static/home/bg_yjc.png",
name: '9vue的H5页面也是如此使用',
commdityPrice: 100
}, {
img: "../../static/home/weixin.png",
name: '10商品的名称,可以很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长',
id: 100
},
], //商品列表,
// 初始化左右盒子
leftList: [],
rightList: [],
// 初始化左右盒子高度
leftH: 0,
rightH: 0
}
},
// 页面加载
onLoad(e) {
this.doList()
},
// 页面显示
onShow() {
},
// 方法
methods: {
doList() {
const that = this
this.list.forEach(res => {
// 获取图片宽高
uni.getImageInfo({
src: res.img,
success: (image) => {
console.log(res.img)
// 计算图片渲染高度
let showH = (50 * image.height) / image.width
// 判断左右盒子高度
if (that.leftH <= that.rightH) {
that.leftList.push(res)
that.leftH += showH
} else {
that.rightList.push(res)
that.rightH += showH
}
}
})
})
}
},
// 计算属性
computed: {
},
// 侦听器
watch: {
},
// 页面隐藏
onHide() {
},
// 页面卸载
onUnload() {
},
// 触发下拉刷新
onPullDownRefresh() {
this.pageNum = 1
// this.getListData()
},
// 页面上拉触底事件的处理函数
onReachBottom() {
this.pageNum++
// this.getListData()
},
}
</script>
<style lang="scss" scoped>
.container {
padding: 0 30rpx;
font-size: 14rpx;
line-height: 24rpx;
}
.right,
.left {
display: inline-block;
width: 40%;
vertical-align: top;
.imgBox{
margin-bottom: 25rpx;
.txt{
font-size: 24rpx;
}
}
}
.left {
float: left;
}
.right{
float: right;
}
.left image,
.right image {
width: 100%;
margin-bottom: 10rpx;
}
</style>
转载:感谢分享
原文链接:https://blog.csdn.net/He_n_ry/article/details/125242284
边栏推荐
- 如何将自己的代码作品快速存证,已更好的保护自己劳动成果
- 同事的接口文档我每次看着就头大,毛病多多。。。
- Jar批量管理小工具
- S32 design studio for arm 2.2 quick start
- Data on the number of functional divisions of national wetland parks in Qinghai Province, data on the distribution of wetlands and marshes across the country, and natural reserves in provinces, cities
- Skills in analyzing the trend chart of London Silver
- 用快解析内网穿透实现零成本自建网站
- [IELTS reading] Wang Xiwei reading P4 (matching1)
- [IELTS reading] Wang Xiwei reads P4 (matching2 paragraph information matching question [difficult])
- JS how to realize array to tree
猜你喜欢
图解网络:什么是网关负载均衡协议GLBP?
Face recognition 5- insight face padding code practice notes
Etcd database source code analysis - brief process of processing entry records
ECCV 2022 | Tencent Youtu proposed disco: the effect of saving small models in self supervised learning
电力运维云平台:开启电力系统“无人值班、少人值守”新模式
Réseau graphique: Qu'est - ce que le Protocole d'équilibrage de charge de passerelle glbp?
Using fast parsing intranet penetration to realize zero cost self built website
高配笔记本使用CAD搬砖时卡死解决记录
[IELTS reading] Wang Xiwei reads P4 (matching2 paragraph information matching question [difficult])
【kotlin】第三天
随机推荐
Design of emergency lighting evacuation indication system for urban rail transit station
How to effectively monitor the DC column head cabinet
Summary of week 22-07-02
Actual combat simulation │ JWT login authentication
If you open an account of Huatai Securities by stock speculation, is it safe to open an account online?
In the enterprise, win10 turns on BitLocker to lock the disk, how to back up the system, how to recover when the system has problems, and how to recover quickly while taking into account system securi
How to avoid arc generation—— Aafd fault arc detector solves the problem for you
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation
Meet ThreadPoolExecutor
Illustrated network: what is gateway load balancing protocol GLBP?
Jar batch management gadget
What is the difference between port mapping and port forwarding
Blue sky nh55 series notebook memory reading and writing speed is extremely slow, solution process record
Parsing of XML
Business implementation - the log is written to the same row of data
[IELTS reading] Wang Xiwei reading P3 (heading)
Solve the problem that the virtual machine cannot be remotely connected through SSH service
电力运维云平台:开启电力系统“无人值班、少人值守”新模式
Consolidated expression C case simple variable operation
Ap8022 switching power supply small household appliances ACDC chip offline switching power supply IC