Ionic 2 - 如何重新计算滚动内容和固定内容的边距

Ionic 2 - How to recalculate margins for scroll-content and fixed-content

我在我的 ionic 2 应用程序中使用 auth0 锁进行身份验证。一旦通过身份验证,用户就会从登录页面转到主页。在将用户发送到主页之前,锁的配置设置为 closable: false 到 运行 一些后台代码。

然而,当我回到家时,我发现我的 scroll-contentfixed-content 都缺少内联 css 的边距。这里也讨论了类似的问题:Using nav.setRoot causes scroll-content to be missing margins for header/footer

有谁知道如何或什么触发了 scroll-contentfixed-content 上的内联 css 的计算和插入?

如果 auth0 锁配置有 autoclose: true,这个问题似乎不会出现,但只有当您手动隐藏锁并继续到另一个页面时才会发生。

您可以使用 ion-content - https://ionicframework.com/docs/api/components/content/Content/

中提供的 resize 方法

您只需:

@ViewChildren(Content) content: Content;

headerUpdated() {
  this.content.resize();
}

调用 resize() 方法后,fixed-contentscroll-content 处的边距将被更新。