ionic-framework - 离子内容方法 scrollToPoint 不适用于 Ionic 5
问题描述
我正在关注这个ionic5和github文档,以便以编程方式将我的页面滚动到一个点。以下是代码
getContent() {
return document.querySelector('ion-content');
}
scrollPage() {
this.getContent().scrollToPoint(100,100);
}
方法scrollToPoint()
是什么都不做。还有另一种调用此方法的方法吗?
解决方案
您不能在选择器获得的项目上应用方法。您必须选择此离子含量@ViewChild
并可以使用以下方法:
@ViewChild(IonContent) content: IonContent;
content.scrollToPoint(100,100);
推荐阅读
- python - 如何删除 Python Numpy 数组中的某些值
- c# - 加载 API 定义失败,获取错误:未定义 /swagger/v1/swagger.json
- python - 在python中用networkx绘制边缘
- azure - 使用通配符从文件中获取 blob 内容
- c - K&R C编程书练习1-18
- git - 如何从 git 终端编辑 .git / config 文件?
- flutter - RenderBox 未布局,Flutter Listview Builder 未显示
- c - 具有双向链表的多项式 - 指针问题
- javascript - 这两个 JavaScript 语句在 React 中的函数式编程规则下是否等效
- openedge - 如何复制文件名并添加前缀?