From fdedea25c89902bfcf0d02290a403d95cbaae9cf Mon Sep 17 00:00:00 2001 From: tangbzai <47456577+tangbzai@users.noreply.github.com> Date: Mon, 9 May 2022 15:48:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B7=B3=E8=BD=AC=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E5=88=B0=E5=8F=AF=E4=B8=8B=E6=8B=89=E5=88=B7=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=97=A0=E6=B3=95=E4=B8=8B=E6=8B=89=E5=88=B7?= =?UTF-8?q?=E6=96=B0=20(#11747)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Zakary --- .../components/pull-to-refresh/pull-to-refresh.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/taro-components/src/components/pull-to-refresh/pull-to-refresh.tsx b/packages/taro-components/src/components/pull-to-refresh/pull-to-refresh.tsx index 3bfea74b1ac6..78d94029e8b4 100644 --- a/packages/taro-components/src/components/pull-to-refresh/pull-to-refresh.tsx +++ b/packages/taro-components/src/components/pull-to-refresh/pull-to-refresh.tsx @@ -57,7 +57,8 @@ export class PullToRefresh implements ComponentInterface { private _isMounted = false; private get scrollContainer () { - return document.querySelector('.taro_page_stationed') || + return this.el.parentElement || + document.querySelector('.taro_page_stationed') || document.querySelector('.taro_page') || document.querySelector('.taro_router') || document.querySelector('.taro-tabbar__panel') || @@ -126,11 +127,11 @@ export class PullToRefresh implements ComponentInterface { init = () => { const ele = this.scrollContainer - const child = this.el.childNodes[this.el.childNodes.length - 1].childNodes[0] - this.el.appendChild = child.appendChild.bind(child) - this.el.insertBefore = child.insertBefore.bind(child) - this.el.replaceChild = child.replaceChild.bind(child) - this.el.removeChild = child.removeChild.bind(child) + const child = this.el.querySelector('rmc-pull-to-refresh-content') + this.el.appendChild = child?.appendChild.bind(child) + this.el.insertBefore = child?.insertBefore.bind(child) + this.el.replaceChild = child?.replaceChild.bind(child) + this.el.removeChild = child?.removeChild.bind(child) this._to = { touchstart: this.onTouchStart.bind(this, ele), touchmove: this.onTouchMove.bind(this, ele),