当前位置:网站首页>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
边栏推荐
- 取得PMP證書需要多長時間?
- 机器人强化学习——Learning Synergies between Pushing and Grasping with Self-supervised DRL (2018)
- 电力运维云平台:开启电力系统“无人值班、少人值守”新模式
- JS convert pseudo array to array
- uniapp 除了数字,其他输入无效
- 端口映射和端口转发区别是什么
- Selected cutting-edge technical articles of Bi Ren Academy of science and technology
- How to save your code works quickly to better protect your labor achievements
- Significance of acrel EMS integrated energy efficiency platform in campus construction
- Mit-6.824-lab4b-2022 (10000 word idea explanation - code construction)
猜你喜欢

【雅思阅读】王希伟阅读P4(matching1)
![[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection](/img/25/e2366cabf00e55664d16455a6049e0.png)
[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection

C language to quickly solve the reverse linked list

js如何实现数组转树
![[JS] - [sort related] - Notes](/img/b7/af467c7a169b73c3c4936072aef8b9.png)
[JS] - [sort related] - Notes

青海省国家湿地公园功能区划数数据、全国湿地沼泽分布数据、全国省市县自然保护区

MIT-6.824-lab4B-2022(万字思路讲解-代码构建)

Hong Kong Jewelry tycoon, 2.2 billion "bargain hunting" Giordano
![[paper reading] cavemix: a simple data augmentation method for brain vision segmentation](/img/41/eb790e7419a158e985fa503bd7dc17.png)
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation

45岁教授,她投出2个超级独角兽
随机推荐
Design of emergency lighting evacuation indication system for urban rail transit station
[ODX studio edit PDX] -0.3- how to delete / modify inherited elements in variant variants
Blue sky nh55 series notebook memory reading and writing speed is extremely slow, solution process record
Fast parsing intranet penetration helps enterprises quickly achieve collaborative office
Fs8b711s14 electric wine bottle opener MCU IC scheme development special integrated IC
PMP certificate renewal process
js如何实现数组转树
Skills in analyzing the trend chart of London Silver
Jar batch management gadget
Life is changeable, and the large intestine covers the small intestine. This time, I can really go home to see my daughter-in-law...
MP advanced operation: time operation, SQL, querywapper, lambdaquerywapper (condition constructor) quick filter enumeration class
雅思考试流程、需要具体注意些什么、怎么复习?
[paper reading] Tun det: a novel network for meridian ultra sound nodule detection
打新债开户注册安全吗?有没有风险的?靠谱吗?
青海省国家湿地公园功能区划数数据、全国湿地沼泽分布数据、全国省市县自然保护区
How to apply for PMP project management certification examination?
Tester's algorithm interview question - find mode
Specification for fs4061a boost 8.4v charging IC chip and fs4061b boost 12.6V charging IC chip datasheet
The input of uniapp is invalid except for numbers
企业里Win10 开启BitLocker锁定磁盘,如何备份系统,当系统出现问题又如何恢复,快速恢复又兼顾系统安全(远程设备篇)