From 69cdf45958ab23c05658f0fd618ebdab83085863 Mon Sep 17 00:00:00 2001 From: nemo-shen Date: Mon, 6 Sep 2021 19:49:54 +0800 Subject: [PATCH] fix(page-scroll): check getCurrentPage is def (#4458) --- packages/mixins/page-scroll.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/mixins/page-scroll.ts b/packages/mixins/page-scroll.ts index 0dfb0018..f427e305 100644 --- a/packages/mixins/page-scroll.ts +++ b/packages/mixins/page-scroll.ts @@ -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) || []; + } }, });