diff --git a/examples/mini-program-example/src/pages/api/wxml/index.tsx b/examples/mini-program-example/src/pages/api/wxml/index.tsx index a2bac0117dee..6d0d30ee7e25 100644 --- a/examples/mini-program-example/src/pages/api/wxml/index.tsx +++ b/examples/mini-program-example/src/pages/api/wxml/index.tsx @@ -268,7 +268,7 @@ class IntersectionObserverTest extends React.Component { this.observer = undefined } this.observer = this.createIntersectionObserver(data) - TestConsole.consoleResult.call(this, this.observer, apiIndex) + TestConsole.consoleResult.call(this, "createIntersectionObserver:ok", apiIndex) }, }, { @@ -282,8 +282,8 @@ class IntersectionObserverTest extends React.Component { this.observer.disconnect() } this.observer = this.createIntersectionObserver() - this.observer.relativeTo('.scroll-view', data).observe('.ball', (res) => { - TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.observe', apiIndex) + this.observer.relativeTo('#IntersectionObserver', data).observe('.ball', (res) => { + TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.relativeTo', apiIndex) this.setState({ appear: res.intersectionRatio > 0, }) @@ -296,13 +296,13 @@ class IntersectionObserverTest extends React.Component { left: 0, }, func: (apiIndex, data) => { - TestConsole.consoleTest('IntersectionObserver.relativeTo') + TestConsole.consoleTest('IntersectionObserver.relativeToViewport') if (this.observer) { this.observer.disconnect() } this.observer = this.createIntersectionObserver() this.observer.relativeToViewport(data).observe('.ball', (res) => { - TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.observe', apiIndex) + TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.relativeToViewport', apiIndex) this.setState({ appear: res.intersectionRatio > 0, }) @@ -338,7 +338,7 @@ class IntersectionObserverTest extends React.Component { return ( IntersectionObserver测试 - + 先创建IntersectionObserver再滚动 diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts index 56d04aea5c18..4bd6a78f2c93 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts @@ -125,7 +125,7 @@ export class TaroHarmonyHybridIntersectionObserver implements Taro.IntersectionO } public relativeToViewport (margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver { - return this.relativeTo('.taro_page', margins) + return this.relativeTo('.taro_router', margins) } private _getCallbackByElement (element: Element) {