Skip to content
On this page

scroll-view

可滚动的视图区域。

Props

参数类型默认值必填说明
scroll-xbooleanfalse允许横向滚动
scroll-ybooleanfalse允许纵向滚动
upper-thresholdnumber | string50距顶部/左边多远时,触发 scrolltoupper 事件
lower-thresholdnumber | string50距底部/右边多远时,触发 scrolltolower 事件
scroll-leftnumber | string设置横向滚动位置
scroll-topnumber | string设置纵向滚动位置
scroll-into-viewstring值应为某子元素id,在可滚动方向滚动到该元素
scroll-with-animationboolean在设置滚动位置时使用动画过渡

Events

事件名说明回调参数
scrolltoupper滚动到顶部/左边时触发{ direction: 'left' | 'top' }
scrolltolower滚动到底部/右边时触发{ direction: 'right' | 'bottom' }
scroll滚动时触发{ scrollLeft: number, scrollTop: number, scrollHeight: number, scrollWidth: number, deltaX: number, deltaY: number }

Example

vue
<template>
   <scroll-view scroll-y class="w-full h-36" @scroll="onScroll">
      <div class="w-full h-36 bg-green-500"></div>
      <div class="w-full h-36 bg-blue-500"></div>
      <div class="w-full h-36 bg-gray-300"></div>
    </scroll-view>
</template>