【问题标题】:ion-content method scrollToPoint not working on Ionic 5离子内容方法 scrollToPoint 不适用于 Ionic 5
【发布时间】:2020-09-06 14:07:57
【问题描述】:

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

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

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

方法scrollToPoint() 没有做任何事情。有没有其他方式调用这个方法?

【问题讨论】:

  • 你解决了吗?我也面临同样的问题。
  • 你能发布你的完整 HTML 和 JS 吗?这种方法对我来说很好。

标签: ionic-framework ionic5


【解决方案1】:

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

@ViewChild(IonContent) content: IonContent;

content.scrollToPoint(100,100);

【讨论】:

    猜你喜欢
    • 2019-11-20
    • 2020-12-05
    • 2018-04-23
    • 1970-01-01
    • 2015-06-20
    • 2018-04-03
    • 2019-02-05
    • 2021-05-06
    • 1970-01-01
    相关资源
    最近更新 更多