首页 > 解决方案 > 离子内容方法 scrollToPoint 不适用于 Ionic 5

问题描述

我正在关注这个ionic5github文档,以便以编程方式将我的页面滚动到一个点。以下是代码

getContent() {
      return document.querySelector('ion-content');
}

scrollPage() {
      this.getContent().scrollToPoint(100,100);
}

方法scrollToPoint()是什么都不做。还有另一种调用此方法的方法吗?

标签: ionic-frameworkionic5

解决方案


您不能在选择器获得的项目上应用方法。您必须选择此离子含量@ViewChild并可以使用以下方法:

@ViewChild(IonContent) content: IonContent;

content.scrollToPoint(100,100);


推荐阅读