当前位置:网站首页>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
边栏推荐
- How to avoid arc generation—— Aafd fault arc detector solves the problem for you
- Some basic functions of enterprise projects are developed, and important things are saved to online first a
- Tester's algorithm interview question - find mode
- go踩坑——no required module provides package : go.mod file not found in current directory or any parent
- 企业里Win10 开启BitLocker锁定磁盘,如何备份系统,当系统出现问题又如何恢复,快速恢复又兼顾系统安全(远程设备篇)
- Verilog tutorial (11) initial block in Verilog
- 45岁教授,她投出2个超级独角兽
- C语言中sizeof操作符的坑
- Acrel-EMS综合能效平台在校园建设的意义
- 巩固表达式C# 案例简单变量运算
猜你喜欢
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation
He worked as a foreign lead and paid off all the housing loans in a year
Réseau graphique: Qu'est - ce que le Protocole d'équilibrage de charge de passerelle glbp?
JS how to realize array to tree
uniapp微信小程序拿来即用的瀑布流布局demo2(方法二)(复制粘贴即可使用,无需做其他处理)
Summer challenge brings you to play harmoniyos multi terminal piano performance
Significance of acrel EMS integrated energy efficiency platform in campus construction
Tester's algorithm interview question - find mode
企业公司项目开发好一部分基础功能,重要的事保存到线上第一a
圖解網絡:什麼是網關負載均衡協議GLBP?
随机推荐
The input of uniapp is invalid except for numbers
[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection
Jar batch management gadget
Is it safe to open and register new bonds? Is there any risk? Is it reliable?
ICML 2022 | 3dlinker: e (3) equal variation self encoder for molecular link design
如何在外地外网电脑远程公司项目?
[JS] - [sort related] - Notes
How to save your code works quickly to better protect your labor achievements
How to avoid arc generation—— Aafd fault arc detector solves the problem for you
Netcore3.1 JSON web token Middleware
A new method for analyzing the trend chart of London Silver
Meet ThreadPoolExecutor
Remember to build wheels repeatedly at one time (the setting instructions of obsidian plug-in are translated into Chinese)
Summer challenge brings you to play harmoniyos multi terminal piano performance
Basic points of the game setup of the points mall
How long does it take to obtain a PMP certificate?
Hologres Query管理及超时处理
45 year old professor, she threw two super unicorns
S32 design studio for arm 2.2 quick start
Instructions for go defer