当前位置:网站首页>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
边栏推荐
- Every time I look at the interface documents of my colleagues, I get confused and have a lot of problems...
- Consolidated expression C case simple variable operation
- [kotlin] the third day
- 如何将自己的代码作品快速存证,已更好的保护自己劳动成果
- JS convert pseudo array to array
- 挖财学院开户安全的吗?开户怎么开?
- [paper reading] cavemix: a simple data augmentation method for brain vision segmentation
- How to effectively monitor the DC column head cabinet
- Réseau graphique: Qu'est - ce que le Protocole d'équilibrage de charge de passerelle glbp?
- Robot reinforcement learning synergies between pushing and grassing with self supervised DRL (2018)
猜你喜欢
Hash table, hash function, bloom filter, consistency hash
Continuous modification of business scenario functions
Solution record of jamming when using CAD to move bricks in high configuration notebook
企业公司项目开发好一部分基础功能,重要的事保存到线上第一a
业务场景功能的继续修改
快解析内网穿透帮助企业快速实现协同办公
[IELTS reading] Wang Xiwei reading P3 (heading)
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
Fs8b711s14 electric wine bottle opener MCU IC scheme development special integrated IC
Tester's algorithm interview question - find mode
随机推荐
Verilog tutorial (11) initial block in Verilog
实战模拟│JWT 登录认证
Financial markets, asset management and investment funds
Parsing of XML
[IELTS reading] Wang Xiwei reading P4 (matching1)
After Microsoft disables the IE browser, open the IE browser to flash back the solution
Summary of week 22-07-02
Is it safe to open an account in the College of Finance and economics? How to open an account?
js如何实现数组转树
Skills in analyzing the trend chart of London Silver
The pit of sizeof operator in C language
French scholars: the explicability of counter attack under optimal transmission theory
模板的进阶
[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection
In June, the list of winners of "Moli original author program" was announced! Invite you to talk about the domestic database
Actual combat simulation │ JWT login authentication
Is it safe to open and register new bonds? Is there any risk? Is it reliable?
Jar批量管理小工具
取得PMP证书需要多长时间?
go踩坑——no required module provides package : go.mod file not found in current directory or any parent