1 .scroll-view
使用竖向滚动时,需要给 一个固定高度,通过 css 设置 height;使用横向滚动时,需要给添加white-space: nowrap;样式。
scroll-y:允许纵向滚动,scroll-x:允许横向滚动
@scroll: 滚动时触发,event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY}
数据双向绑定
<template>
<view>
<scroll-view class="scroll" scroll-y="true" @scroll="scroll">
<view v-for="i in 100">{{i}}</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
flag:true
}
},
methods: {
scroll(e){
console.log(e.detail);
}
}
}
</script>
<style>
.scroll{
height:400rpx;
}
</style>