无法捕获滚动事件 IONIC V3



我似乎无法从 Ionic 3 中的离子含量中捕获滚动事件。 我需要div 元素中的每个滚动来捕获滚动事件以执行一些相关的计算。

我已经尝试了几种方法,包括将 EventEmitter (ionScroll( 绑定到 HTML 文件中的方法,或者将 ion-content 声明为 viewchild 并尝试在 ngAfterViewInit(( 方法中订阅它,但没有一种奏效。

我要绑定的方法很简单:

scrolling(event) {
console.log(event);
}

文件:

<ion-content    style="height: 20000px;" (ionScroll)="scrolling($event)" >
</ion-content>

值得一提的是,这是项目主页.html页面中的一个组件。

我做错了什么?

import {Component, ViewChild} from '@angular/core';
import {Content} from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class ProjectPage {
@ViewChild(Content) content:Content;
ngAfterViewInit() {
this.content.addScrollListener((event) =>  {
//on scroll fire
});
}
}

最新更新