fix(page-scroll): check getCurrentPage is def (#4458)

This commit is contained in:
nemo-shen 2021-09-06 19:49:54 +08:00 committed by GitHub
parent 84113ffd17
commit 69cdf45958
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { getCurrentPage } from '../common/utils';
import { getCurrentPage, isDef } from '../common/utils';
type IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption;
type Scroller = (
@ -38,7 +38,9 @@ export const pageScrollMixin = (scroller: Scroller) =>
detached() {
const page = getCurrentPage<{ vanPageScroller: Scroller[] }>();
page.vanPageScroller =
page.vanPageScroller?.filter((item) => item !== scroller) || [];
if (!isDef(page)) {
page.vanPageScroller =
page.vanPageScroller?.filter((item) => item !== scroller) || [];
}
},
});