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 3bfea74b1ac..78d94029e8b 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),