Skip to content

ScrollList 横向滚动列表

横向滚动列表组件,支持自定义列表项、尾部插槽、加载更多等功能。

平台兼容性

App(vue)App(nvue)H5小程序

代码示例

基础用法

传入 list 数据,默认横向滚动。

html
<see-scroll-list :list="['推荐', '热门', '关注', '科技', '财经']">
  <template #item="{ item }">
    <view class="scroll-item">
      <text>{{ item }}</text>
    </view>
  </template>
</see-scroll-list>

自定义项样式

通过 item-gap 设置间距,配合自定义插槽实现个性化样式。

html
<see-scroll-list :list="list" item-gap="24rpx">
  <template #item="{ item }">
    <view class="custom-item" :style="{ backgroundColor: item.color }">
      <text>{{ item.label }}</text>
    </view>
  </template>
</see-scroll-list>

尾部插槽

使用 footer 插槽添加"更多"按钮等尾部内容。

html
<see-scroll-list :list="list">
  <template #item="{ item }">
    <view class="scroll-item">
      <text>{{ item }}</text>
    </view>
  </template>
  <template #footer>
    <view @click="handleMore">
      <text>更多 ></text>
    </view>
  </template>
</see-scroll-list>

加载更多

监听 onScrollToLower 事件实现加载更多功能。

html
<see-scroll-list :list="list" @on-scroll-to-lower="onLoadMore">
  <template #item="{ item }">
    <view class="scroll-item">
      <text>{{ item.title }}</text>
    </view>
  </template>
</see-scroll-list>
javascript
const onLoadMore = () => {
  // 加载更多数据
  list.value.push(...newData)
}

纵向滚动

设置 scroll-xfalsescroll-ytrue 可切换为纵向滚动模式。

html
<see-scroll-list :list="list" :scroll-x="false" :scroll-y="true" style="height: 300rpx;">
  <template #item="{ item }">
    <view class="scroll-item">
      <text>{{ item }}</text>
    </view>
  </template>
</see-scroll-list>

API

Props

参数说明类型默认值可选值
list数据列表any[][]-
scroll-x是否允许横向滚动booleantruetrue / false
scroll-y是否允许纵向滚动booleanfalsetrue / false
show-scrollbar是否显示滚动条booleanfalsetrue / false
is-animated是否启用滚动动画booleantruetrue / false
padding-left左侧间距string'30rpx'-
item-gap列表项间距string'20rpx'-
load-more-threshold触发加载更多的距离阈值(px)number50-

Events

事件名说明回调参数
onScroll滚动时触发event: any - 滚动事件对象
onScrollToLower滚动到底部/右侧时触发-
onScrollToUpper滚动到顶部/左侧时触发-

Slots

插槽名说明插槽参数
item自定义列表项内容{ item: any, index: number }
footer尾部内容-

辽 ICP 备 2025070134 号