我们正在使用 Ionic v1.3.1 开发适用于 iPad 的移动应用程序。
在我们的其中一个页面中,离子内容的底部有一个 ul 元素。
当我们通过单击 ul 元素打开列表时,列表会打开并且离子内容的高度发生变化,但内容不会向下滚动,因此只要我们不滚动,我们就看不到打开的列表手动下。
我们尝试通过以下代码向下滚动到内容底部。
代码正确获取内容,但 scrollToBottom 不会滚动到底部。
var element = document.getElementById("myContent");
if (element){
element.content.scrollToBottom();
}
页面中的内容定义如下:
<ion-content id="myContent" class="padding has-header" scroll="true" style="overflow: scroll;">
有谁知道该怎么做才能让它发挥作用?任何帮助,将不胜感激。
帕特里克
ES2015/ES6 样式 ScrollToBottom
import {ViewChild} from 'angular2/core';
import {Page,Content} from 'ionic-angular';
@Page({
templateUrl: 'build/pages/page1/page1.html',
queries: {
content: new ViewChild(Content)
}
})
export class Page1 {
constructor() {
}
scrollToBottom(){
let dimensions = this.content.getContentDimensions();
this.content.scrollTo(0, dimensions.scrollBottom, 0);
}
}
您可能需要添加:
@ViewChild(Content) content: Content;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句