[youzan/vant]popup中滚动报错

2024-05-22 891 views
5

<van-popup v-model="showDetail" position="right"></van-popup> <van-nav-bar title="汇报详情" left-text="取消" fixed=""></van-nav-bar>
  <task></task>

在一个子组件中使用了Popup,里面包含一个NavBar和task(子组件),目前出现的问题有两个:

  1. NavBar 定义了 fixed,但是在滚动的时候NavBar并没有固定在顶部
  2. popup滚动到顶部和底部的时候,会报错,错误提示:[Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted.

回答

8

我也遇到了。Popup的子元素无法使用fixed定位

2

感觉这个方案不是特别理想

3

试了一下,禁用了动画之后这两个问题都没有解决

4

试了一下,禁用了动画之后这两个问题都没有解决 其他组件库,vux或者mint-ui,在Popup 里都是可以使用fixed定位的,也有动画

7

修改源码,在vant/es/mixins/popup/index.js 文件里的找到onTouchMove方法,找到e.preventDefault(); e.stopPropagation();的执行条件判断语句,在if里加入一条判断 e.cancelable,亲测有效。 if (status !== '11' && e.cancelable && this.direction === 'vertical' && !(parseInt(status, 2) & parseInt(direction, 2))) { e.preventDefault(); e.stopPropagation(); }