小编Geo*_*ule的帖子

我该如何解决 - “动作”类型上不存在属性“地图”

下面的代码片段是我的 ionic3/angularfire2 项目的一部分。它连接到 Firestore 数据库 - 并应返回文档的可观察快照。

从我的网络研究中,我可以看到其他人使用了类似的语法 - 我找不到我的解决方案

// (all other imports are fine)

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
Run Code Online (Sandbox Code Playgroud)

在构造函数中,我注入...

private db: AngularFirestore
Run Code Online (Sandbox Code Playgroud)

下面的代码有错误(我很不高兴)

// customerRef: AngularFirestoreDocument<Customer>;
this.customerRef = this.db.doc(`customers/${k}`);

// cust: Observable<Customer>;
this.cust = this.customerRef.snapshotChanges().map(actions => {
  return actions.map(action => {
    const data = action.payload.doc.data() as Customer;
    const id = action.payload.doc.id;
    console.log('>>>>', { id, ...data });
    return { id, ...data };
  });
});
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

Typescript Error
Property 'map' does not exist on type 'Action<DocumentSnapshot>'. …
Run Code Online (Sandbox Code Playgroud)

dictionary ionic-framework angularfire2 angular

6
推荐指数
1
解决办法
2766
查看次数