uni-app中uni-popup组件的scroll-view在微信小程序上无法滚动 但在App上可以滚动

uni-app中uni-popup组件的scroll-view在微信小程序上无法滚动 但在App上可以滚动

示例代码:

直接运行点击打开popup即可复现  

操作步骤:

看代码  

预期结果:

看代码  

实际结果:

看代码  

bug描述:

uni-popup中使用scroll-view内容无法滚动,真机也无法滚动,不过在模拟器上可以使用滚轮滚动,但是放在页面上可以滚动  

bug附件:

信息类别 详细信息
产品分类 uniapp/小程序/微信
PC开发环境 Windows
PC开发环境版本 win10专业版 21H1
HBuilderX类型 正式
HBuilderX版本 3.4.7
工具版本号 1.05.2204050
基础库版本号 2.24.2
项目创建方式 HBuilderX

更多关于uni-app中uni-popup组件的scroll-view在微信小程序上无法滚动 但在App上可以滚动的实战教程也可以访问 https://www.itying.com/category-93-b0.html

12 回复
<view> <uni-popup ref="popup" type="bottom" @maskClick="maskClickFn" [@touchmove](/user/touchmove).stop.prevent @close="show = false"> <uni-transition modeClass="slide-bottom" :styles="{ height: '60vh', width: '100%' }" :show="show"> <view class="popup-content"> <view class="u-flex popup-title"> <view class="u-font-28 btn cancel-btn" @click="canenlBtnFn">取消</view> <view class="u-flex-1 u-font-32">{{title}}</view> <view class="u-font-28 btn confirm-btn" @click="confirmBtnFn">确定</view> </view> <view class="tree-content"> <scroll-view scroll-y scroll-x style="width: 100%;height: 100%;white-space: nowrap;"> </scroll-view> </view> </view> </uni-transition> </uni-popup> </view> [@touchmove](/user/touchmove).stop.prevent 导致不能滚动的根本原因 其次,为什么要在 uni-popup 里套一个 uni-transition ?

更多关于uni-app中uni-popup组件的scroll-view在微信小程序上无法滚动 但在App上可以滚动的实战教程也可以访问 https://www.itying.com/category-93-b0.html


因为不嵌套uni-transition根本就没动画,其次,@touchmove.stop.prevent在app上是可以的,就是为了防止滚动穿透

并且去掉uni-transition给.popup-content设置高度也不能滚动

@touchmove.stop.prevent 是这个的锅,但是为啥app上有用

回复 [已删除]: 使用 @touchmove.stop.prevent 就会导致所有元素都无法滚动

回复 [已删除]: uni-popup 本来就有动画

回复 DCloud_UNI_HT: 但是我把uni-transition去掉就没有动画

没用,建议你们跑起来试试

回复 [已删除]: 你自己封装组件的问题

<uni-popup ref=“popup” background-color="#fff" @change=“change”>
<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">

<scroll-view :scroll-top=“scrollTop” scroll-y=“true” class=“scroll-Y” @scrolltoupper=“upper” @scrolltolower=“lower”
@scroll=“scroll”>
<view id="demo1" class="scroll-view-item uni-bg-red">A</view>
<view id="demo2" class="scroll-view-item uni-bg-green">B</view>
<view id="demo3" class="scroll-view-item uni-bg-blue">C</view>
</scroll-view>
</view>
</uni-popup> 我的再快手小程序中也无法滚动,但是微信何字节能正常滚动

uni-app 中使用 uni-popup 组件时,如果在微信小程序上遇到 scroll-view 无法滚动的问题,而在 App 上可以正常滚动,可能是由于微信小程序的特定限制或样式问题导致的。以下是一些可能的原因和解决方案:

1. 检查 scroll-view 的高度

scroll-view 需要设置一个明确的高度才能正常工作。如果高度设置不正确,可能会导致无法滚动。确保 scroll-view 的高度是固定的或者基于父容器的高度动态计算的。

<uni-popup ref="popup">
  <scroll-view style="height: 300px;" scroll-y>
    <!-- 内容 -->
  </scroll-view>
</uni-popup>

2. 检查 CSS 样式

微信小程序对 scroll-view 的样式有一些特殊要求。确保 scroll-view 的样式没有冲突,并且没有设置 overflow: hidden 或其他可能影响滚动的样式。

scroll-view {
  height: 100%;
  overflow-y: scroll;
}

3. 使用 enable-flex 属性

在微信小程序中,scroll-view 默认不支持 Flex 布局。如果你在 scroll-view 中使用了 Flex 布局,可以尝试添加 enable-flex 属性。

<scroll-view style="height: 300px;" scroll-y enable-flex>
  <!-- 内容 -->
</scroll-view>

4. 检查 uni-popupmask 属性

uni-popupmask 属性可能会影响 scroll-view 的滚动。你可以尝试禁用 mask 或者调整 mask 的样式。

<uni-popup ref="popup" :mask="false">
  <scroll-view style="height: 300px;" scroll-y>
    <!-- 内容 -->
  </scroll-view>
</uni-popup>

5. 使用 scroll-topscroll-left 属性

如果 scroll-view 的内容没有变化,但无法滚动,可以尝试使用 scroll-topscroll-left 属性来强制滚动。

<scroll-view style="height: 300px;" scroll-y :scroll-top="scrollTop">
  <!-- 内容 -->
</scroll-view>
export default {
  data() {
    return {
      scrollTop: 0
    };
  },
  methods: {
    scrollToTop() {
      this.scrollTop = this.scrollTop ? 0 : 1;
    }
  }
};

6. 检查微信小程序的版本

某些微信小程序的版本可能存在兼容性问题。确保你的微信小程序基础库版本是最新的,或者尝试在不同的版本上测试。

7. 使用 scroll-viewscroll-with-animation 属性

如果滚动效果不流畅,可以尝试使用 scroll-with-animation 属性来启用动画滚动。

<scroll-view style="height: 300px;" scroll-y scroll-with-animation>
  <!-- 内容 -->
</scroll-view>

8. 检查 uni-popupposition 属性

uni-popupposition 属性可能会影响 scroll-view 的布局。确保 position 设置正确,不会导致 scroll-view 的布局异常。

<uni-popup ref="popup" position="bottom">
  <scroll-view style="height: 300px;" scroll-y>
    <!-- 内容 -->
  </scroll-view>
</uni-popup>

9. 使用 scroll-viewscroll-into-view 属性

如果你需要滚动到特定的子元素,可以使用 scroll-into-view 属性。

<scroll-view style="height: 300px;" scroll-y :scroll-into-view="scrollIntoViewId">
  <view id="item1">Item 1</view>
  <view id="item2">Item 2</view>
  <view id="item3">Item 3</view>
</scroll-view>
export default {
  data() {
    return {
      scrollIntoViewId: 'item1'
    };
  },
  methods: {
    scrollToItem(itemId) {
      this.scrollIntoViewId = itemId;
    }
  }
};

10. 检查 uni-popupz-index 属性

如果 uni-popupz-index 设置不当,可能会导致 scroll-view 被其他元素遮挡。确保 z-index 设置正确。

.uni-popup {
  z-index: 1000;
}
回到顶部