[英]How to set start y-position of ion-content scroll?
I'm trying to set up the scroll position of ion-content
a little bit down to hide some elements at the beginning of this control. 我试图稍微降低
ion-content
的滚动位置,以在此控件的开头隐藏一些元素。
I need something like this 我需要的东西像这样
I have tried 'start-y="xx"' attribute but it doesn't work. 我已经尝试过'start-y =“ xx”'属性,但是它不起作用。
Any suggestions? 有什么建议么?
<ion-content start-y="55">
In ionic4 there currently isn't an attribute for scroll starting position. 在ionic4中,当前没有滚动开始位置的属性。 However, there is a scroll method you can use on page initialisation which you can use like so:
但是,可以在页面初始化中使用滚动方法,如下所示:
.ts .ts
import { Component, ViewChild } from '@angular/core';
import {IonContent} from '@ionic/angular';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
@ViewChild(IonContent) theContent: IonContent;
ngOnInit() {this.theContent.scrollToPoint(0,150).then(()=>{}) }
}
}
comment if you need anything clarifying 如果您需要任何澄清,请发表评论
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.