Javascript 爱奥尼亚+;Firebase-实时数据库未更新视图

Javascript 爱奥尼亚+;Firebase-实时数据库未更新视图,javascript,angular,ionic-framework,firebase-realtime-database,ionic2,Javascript,Angular,Ionic Framework,Firebase Realtime Database,Ionic2,我的申请有一个很奇怪的问题。为了显示实时数据库,我必须与应用程序交互。2个月前,我没有这个问题,信息显示正常,但现在,我必须点击一个按钮或东西,以便视图更新 我在这里快速制作了一个GIF: 如果您在我单击有此问题的任何其他人的时暂停,那么对我来说,NgZone就是答案 我导入了它: import { NgZone } from '@angular/core'; 将其添加到构造函数中: public zone: NgZone, 然后将它包装在我的firebase代码中: this.zone

我的申请有一个很奇怪的问题。为了显示实时数据库,我必须与应用程序交互。2个月前,我没有这个问题,信息显示正常,但现在,我必须点击一个按钮或东西,以便视图更新

我在这里快速制作了一个GIF:


如果您在我单击有此问题的任何其他人的
时暂停,那么对我来说,
NgZone
就是答案

我导入了它:

import { NgZone } from '@angular/core';
将其添加到构造函数中:

public zone: NgZone,
然后将它包装在我的firebase代码中:

  this.zone = new NgZone({});
  if(fromClick) { this.subscription.off(); }
  this.postFeed = new Array();
  this.subscription = this.database.database.ref('/posts/'+this.locationId)
  .orderByChild('score')
  .limitToLast(10);
  this.subscription.on('child_added', (snapshot) => {
    this.zone.run(() => {
        this.postFeed.push(snapshot.val())
     }):
  });

这对我来说非常有效。我找不到问题的真正原因,但我只是将
NgZone
代码包装在我所有的firebase函数中,它像以前一样工作。如果其他人有更多信息,那就太好了。

我的代码片段最近也坏了,我没有更新任何代码或本地依赖项。因此,似乎值得检查firebase最近是否做了任何突破性的更改。在您开始使用WKWebView之后,是否开始发生这种情况
public zone: NgZone,
  this.zone = new NgZone({});
  if(fromClick) { this.subscription.off(); }
  this.postFeed = new Array();
  this.subscription = this.database.database.ref('/posts/'+this.locationId)
  .orderByChild('score')
  .limitToLast(10);
  this.subscription.on('child_added', (snapshot) => {
    this.zone.run(() => {
        this.postFeed.push(snapshot.val())
     }):
  });