Skip to content

t-waterflow

Waterflow 瀑布流

组件介绍

t-waterflow 是瀑布流容器组件,用于多列不等高内容布局与滚动加载。配合 t-waterfall-item 使用实现瀑布流效果,支持下拉刷新和上拉加载更多。

平台兼容

HarmonyH5AndroidiOS小程序UTS

基础用法

基础用法参考 demo/waterflow/waterflow.uvue,配合 t-waterfall-item 使用。

vue
<template>
  <t-waterflow 
    :loadmore="true" 
    :refresherEnabled="true"
    @scrolltolower="loadMore"
    @refresherrefresh="onRefresh">
    <t-waterfall-item v-for="(item, index) in goods" :key="index">
      <view class="card">
        <image :src="item.image" mode="widthFix"></image>
        <text>{{ item.name }}</text>
        <text>{{ item.price }}</text>
      </view>
    </t-waterfall-item>
  </t-waterflow>
</template>

<script setup>
const goods = ref<UTSJSONObject[]>([])

function loadMore() {
}

function onRefresh() {
}
</script>

Props

属性名说明类型默认值
crossAxisCount列数number2
mainAxisGap主轴间距number10
crossAxisGap交叉轴间距number10
padding内边距 [上,右,下,左]number[][10, 10, 10, 10]
loadmore是否开启上拉加载booleanfalse
loadmoreBoxClass加载更多区域样式string''
refresherEnabled是否开启下拉刷新booleanfalse
refresherThreshold下拉刷新阈值number45
refresherMaxDragDistance下拉最大距离number80
refresherBackground下拉刷新区域背景色string'transparent'
refresherTriggered是否触发下拉刷新booleanfalse
refresherBoxClass下拉刷新区域样式string''
bounces是否开启回弹booleantrue
showScrollbar是否显示滚动条booleanfalse
scrollTop滚动位置number0
scrollIntoView滚动到指定元素string''
scrollWithAnimation滚动是否使用动画booleantrue
upperThreshold距顶部多远触发事件number50
lowerThreshold距底部多远触发事件number50

Events

事件名说明回调参数
scrolltolower滚动到底部时触发() => void
scrolltoupper滚动到顶部时触发() => void
scroll滚动时触发(e: UniScrollEvent) => void
scrollend滚动结束时触发() => void
refresherrefresh下拉刷新时触发() => void
refresherpulling下拉过程中触发(e: UniEvent) => void
refresherrestore下拉刷新复位时触发() => void
refresherabort下拉刷新中止时触发() => void