【bug】scroll-view内元素bindlongpress无效

发布于 6 年前作者 jun2815739 次浏览最后编辑 6 年前来自 ask

scroll-view在设置了scroll-y以及scroll-into-view之后,每次数据增加就自动滚动到最后一个item,item设置bindlongpress,自动滚动停止以后,长按item无法触发监听事件;当手动滚动scroll-view内部之后,长按item可以触发监听事件,demo代码:

<scroll-view class=“scroll_view” scroll-into-view=“{{scrollIntoView}}” scroll-y>

    <view

        wx:for=“{{scrollList}}”

        wx:key=“{{item.id}}”

        bindlongpress=“longpress”

        id=“item_{{item.id}}”

        class=“item”

    >

        {{item.cnt}}

    </view>

</scroll-view>

Page({

    data: {

        scrollList: [],

        scrollIntoView: ‘’

    },

    onReady() {

        this.startTestScroll();

    },

    startTestScroll() {

        const that = this;

        const { scrollList } = this.data;

        

        const time = new Date().getTime();

        const item = {

            id: time,

            cnt: time

        };

        

        scrollList.push(item);

        that.setData({

            scrollList,

            scrollIntoView: ‘item_’ + item.id

        });

        

        if (scrollList.length < 10) {

            setTimeout(() => {

                that.startTestScroll();

            }, 600);

        }

    },

    longpress() {

        wx.showToast({

            title: ‘长按成功!’

        });

    }

})

10 回复
wanxiulan
wanxiulan1 楼6 年前

longpress真的很重要,官方想办法解决下这个问题吧

hliang
hliang2 楼6 年前

在近期版本(预计是2.1.0)里会针对滚动结束后的长按进行改进。

taoqin
taoqin3 楼6 年前

我的也是 没在scroll-view里也bindlongpress偶尔失效 需要手动动一下页面

为啥这么多人有这个问题 官方就没人来解答一下呢

yangzheng
yangzheng4 楼6 年前

官方能不能负责任一点?

wanli
wanli5 楼6 年前

确实会偶尔失效

qdai
qdai6 楼6 年前

我也是,真机(iphone 7 plus),最新wechat,普通的view,longpress偶尔无法触发。

yang68
yang687 楼6 年前

没人解决吗

weiwan
weiwan8 楼6 年前

认认真真地写好了demo,都是花了时间的,发完也没有人理一下?

gyin
gyin9 楼6 年前

不仅是scrow-view. 我在普通view里的bindlongpress再模拟器上正常, 在真机上就无效了. 环境跟你一样.

oxue
oxue10 楼4 年前

为什么我发的每个贴都能沉了?