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>

总结

本篇文章就到这里了,希望能够给你带来帮助,也希望您能够多多关注www.887551.com的更多内容!