fix(tab): fix maximum call stack on scroll (#5125)

This commit is contained in:
landluck 2022-12-02 10:19:26 +08:00 committed by GitHub
parent 71f5e3422f
commit 5b96c7acb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,6 @@ function onPageScroll(event?: IPageScrollOption) {
});
}
export function pageScrollMixin(scroller: Scroller) {
return Behavior({
attached(this: WechatMiniprogram.Component.TrivialInstance) {
@ -34,7 +33,7 @@ export function pageScrollMixin(scroller: Scroller) {
const { vanPageScroller = [] } = page;
if (!vanPageScroller.length && isFunction(page.onPageScroll)) {
if (isFunction(page.onPageScroll) && page.onPageScroll !== onPageScroll) {
vanPageScroller.push(page.onPageScroll.bind(page));
}
@ -55,7 +54,7 @@ export function pageScrollMixin(scroller: Scroller) {
const { vanPageScroller } = page;
const index = vanPageScroller.findIndex(v => v === this._scroller);
const index = vanPageScroller.findIndex((v) => v === this._scroller);
if (index > -1) {
page.vanPageScroller.splice(index, 1);