r***@126.com
r***@126.com
  • 发布:2025-05-20 13:02
  • 更新:2025-05-20 13:23
  • 阅读:22

nvue页面list组件和scroll-view组件在页面内容超过一屏情况下就不滚动

分类:uni-app

这也太坑了吧,nvue没有区域滚动方案了吗?
<template>
<view>
<scroll-view :scroll-top="scrollTop" scroll-y="true" scroll-x="true" class="scroll-Y" @scrolltoupper="upper"
@scrolltolower="lower" @scroll="scroll" style="height: 100px;">
<view id="demo1" class="scroll-view-item " style="background-color: red;">A</view>
<view id="demo2" class="scroll-view-item "style="background-color: green;">B</view>
<view id="demo3" class="scroll-view-item "style="background-color: blue;">C</view>
</scroll-view>
</view>
<view style="height: 4000px;"></view>
</template>

<script>
export default {
data() {
return {
scrollTop: 0,
old: {
scrollTop: 0
}
}
},
methods: {
upper: function(e) {
console.log(e)
},
lower: function(e) {
console.log(e)
},
scroll: function(e) {
console.log(e)
this.old.scrollTop = e.detail.scrollTop
},
goTop: function(e) {
// 解决view层不同步的问题
this.scrollTop = this.old.scrollTop
this.$nextTick(function() {
this.scrollTop = 0
});
uni.showToast({
icon: "none",
title: "纵向滚动 scrollTop 值已被修改为 0"
})
}
}
}
</script>

<style>
.scroll-Y {
height: 300rpx;
}
.scroll-view_H {
white-space: nowrap;
width: 100%;
}
.scroll-view-item {
width: 720rpx;
height: 300rpx;
line-height: 300rpx;
text-align: center;
font-size: 36rpx;
}

</style>

2025-05-20 13:02 负责人:无 分享
已邀请:
吃俺老孙一棒

吃俺老孙一棒 - 狼行千里吃肉,狗行千里吃屎

不理解你写这个<view style="height: 4000px;"></view>是干什么用的,正常nvue页面,区域滚动 scrollview可以正常使用

  • r***@126.com (作者)

    <view style="height: 4000px;"></view>就是超过一屏的高度的

    2025-05-20 13:43

要回复问题请先登录注册