uniapp实现列表瀑布流
时间: 2023-10-01 10:05:00 浏览: 89
要在Uniapp中实现瀑布流列表,你可以使用uni-list组件并设置为waterfall模式。以下是示例代码:
``` html
<template>
<view>
<uni-list :waterfall="true">
<uni-list-item v-for="(item, index) in list" :key="index" :thumb="item.thumb" :title="item.title"></uni-list-item>
</uni-list>
</view>
</template>
<script>
export default {
data() {
return {
list: [
{ title: 'Item 1', thumb: 'https://picsum.photos/id/1/200/200' },
{ title: 'Item 2', thumb: 'https://picsum.photos/id/2/200/200' },
{ title: 'Item 3', thumb: 'https://picsum.photos/id/3/200/200' },
{ title: 'Item 4', thumb: 'https://picsum.photos/id/4/200/200' },
{ title: 'Item 5', thumb: 'https://picsum.photos/id/5/200/200' },
{ title: 'Item 6', thumb: 'https://picsum.photos/id/6/200/200' },
{ title: 'Item 7', thumb: 'https://picsum.photos/id/7/200/200' },
{ title: 'Item 8', thumb: 'https://picsum.photos/id/8/200/200' },
{ title: 'Item 9', thumb: 'https://picsum.photos/id/9/200/200' },
{ title: 'Item 10', thumb: 'https://picsum.photos/id/10/200/200' }
]
}
}
}
</script>
```
在上面的代码中,我们使用了uni-list组件,并将其设置为waterfall模式。然后,我们通过v-for指令将列表项渲染到页面上。每个列表项都由uni-list-item组件表示,并且我们设置了标题和缩略图。这样,我们就可以在Uniapp中实现瀑布流列表了。
阅读全文