现在已经清楚了。滚动事件是派发在 GPanel(owner)上的,不是在 scroller 对象上。文档里 aPanel.scroller.on(...) 的写法是错误的。
正确写法应该是:
this.examItemParent.on(Laya.UIEvent.Scroll, () => { ... });
用户截图中下半部分已经用了类似写法。让我确认 isBottomMost 属性可以用来判断到底:
从 IScroller 接口可以看到有 isBottomMost 属性。用户可以这样判断滚动到底部。
滚动事件是在 GPanel 上监听的,不是在 scroller 上。文档里 aPanel.scroller.on(...) 的写法有误,scroller 是 IScroller 接口,没有 on 方法。
正确的写法是直接在 GPanel 上监听:
this.examItemParent.on(Laya.UIEvent.Scroll, () => {
if (this.examItemParent.scroller.isBottomMost) {
// 滚动到底部,加载更多数据
}
});
UIEvent.Scroll 的值就是 "scroll",所以写 this.examItemParent.on("scroll", ...) 也行。判断是否到底可以用 scroller.isBottomMost,或者比较 scroller.percY >= 1。
以上由 AI 自动回复,仅供参考。若无异议将不再人工审查;如需人工介入请回帖说明。