当前位置:网站首页>The waterfall flow layout demo2 (method 2) used by the uniapp wechat applet (copy and paste can be used without other processing)
The waterfall flow layout demo2 (method 2) used by the uniapp wechat applet (copy and paste can be used without other processing)
2022-07-05 00:05:00 【I'm happy】
design sketch :
<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 Name of commodity , Can be very long, very long, very long, very long, very long, very long, very long, very long, very long, very long, very long, very long ',
id: 100
}, {
img: "../../static/home/bg_yjc.png",
name: '1 Name of commodity , Can be very long, very long, very long, very long, very long, very long, very long, very long, very long, very long, very long, very long ',
id: 100
}, {
img: "../../static/home/bg.png",
name: '2 The product name will exceed N Do not fold on line ',
id: 100
},
{
img: "../../static/home/bg.png",
name: '3 When there are only two lines of titles, the height is 39',
id: 100
}, {
img: "../../static/home/bg.png",
name: '4 You can customize the specific style ',
id: 100
}, {
img: "../../static/home/bg_yjc.png",
name: '5vue Of H5 The same is true for pages ',
id: 100
}, {
img: "../../static/img/shenfen1.png",
name: '6 When there is only one line of title ',
id: 100
}, {
img: "../../static/home/bg_yjc.png",
name: '7vue Of H5 The same is true for pages ',
commdityPrice: 100
}, {
img: "../../static/home/bg.png",
name: '8vue Of H5 The same is true for pages ',
commdityPrice: 100
}, {
img: "../../static/home/bg_yjc.png",
name: '9vue Of H5 The same is true for pages ',
commdityPrice: 100
}, {
img: "../../static/home/weixin.png",
name: '10 Name of commodity , Can be very long, very long, very long, very long, very long, very long, very long, very long, very long, very long, very long, very long ',
id: 100
},
], // List of goods ,
// Initialize left and right boxes
leftList: [],
rightList: [],
// Initialize the height of the left and right boxes
leftH: 0,
rightH: 0
}
},
// Page loading
onLoad(e) {
this.doList()
},
// Page shows
onShow() {
},
// Method
methods: {
doList() {
const that = this
this.list.forEach(res => {
// Get the width and height of the picture
uni.getImageInfo({
src: res.img,
success: (image) => {
console.log(res.img)
// Calculate the image rendering height
let showH = (50 * image.height) / image.width
// Judge the height of the left and right boxes
if (that.leftH <= that.rightH) {
that.leftList.push(res)
that.leftH += showH
} else {
that.rightList.push(res)
that.rightH += showH
}
}
})
})
}
},
// Compute properties
computed: {
},
// The listener
watch: {
},
// Page hidden
onHide() {
},
// Page uninstall
onUnload() {
},
// Trigger pull-down refresh
onPullDownRefresh() {
this.pageNum = 1
// this.getListData()
},
// Handling function of page pull bottom event
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>
Reprint : Thanks for sharing.
Link to the original text :https://blog.csdn.net/He_n_ry/article/details/125242284
边栏推荐
- PaddleOCR教程
- 实战模拟│JWT 登录认证
- MIT-6.824-lab4B-2022(万字思路讲解-代码构建)
- Jar batch management gadget
- 【雅思阅读】王希伟阅读P3(Heading)
- Mit-6.824-lab4b-2022 (10000 word idea explanation - code construction)
- [paper reading] cavemix: a simple data augmentation method for brain vision segmentation
- 端口映射和端口转发区别是什么
- 人生无常,大肠包小肠, 这次真的可以回家看媳妇去了。。。
- PMP certificate renewal process
猜你喜欢
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 long does it take to obtain a PMP certificate?
同事的接口文档我每次看着就头大,毛病多多。。。
如何避免电弧产生?—— AAFD故障电弧探测器为您解决
js如何实现数组转树
Acrel-EMS综合能效平台在校园建设的意义
OpenHarmony资源管理详解
用快解析内网穿透实现零成本自建网站
人脸识别5- insight-face-paddle-代码实战笔记
Continuous modification of business scenario functions
随机推荐
How to effectively monitor the DC column head cabinet
Using the uniapp rich text editor
Fs8b711s14 electric wine bottle opener MCU IC scheme development special integrated IC
业务实现-日志写到同一个行数据里面
【kotlin】第三天
[path planning] RRT adds dynamic model for trajectory planning
打新债开户注册安全吗?有没有风险的?靠谱吗?
PMP certificate renewal process
A new method for analyzing the trend chart of London Silver
[JS] - [dynamic planning] - Notes
[ODX studio edit PDX] -0.3- how to delete / modify inherited elements in variant variants
多回路仪表在基站“转改直”方面的应用
香港珠宝大亨,22亿“抄底”佐丹奴
[IELTS reading] Wang Xiwei reading P3 (heading)
22-07-02周总结
Design of emergency lighting evacuation indication system for urban rail transit station
Skills in analyzing the trend chart of London Silver
[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection
「运维有小邓」域密码策略强化器
Summary of week 22-07-02