使用angularFire2推送数据时如何处理错误?我使用以下方法:todoLists: AngularFireList<TodoList>;addList(data): ThenableReference { const item: Item = { name: data.task, state: false, description: 'No description' }; const todoList: TodoList = { id: '', name: data.name, items: [item] }; this.todoLists.push(todoList).then(_ => this.presentToast('List succesfuly added')) .catch(err => _ => this.presentToast('Something wrong happened')); }这里的问题是AngularFire的push方法返回一个ThenableReference,因此该接口中不存在catch方法。这是来自编辑器的消息(vscode)  属性承诺在类型promiseLike 中不存在  必须有另一种方法来处理错误。 (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 我遇到了同样的问题,我发现我可以使用push()方法创建thenable引用,然后使用set来在.catch上返回错误。查看更多here in the docs。todoLists: AngularFireList<TodoList>;addList(data): void { const item: Item = { name: data.task, state: false, description: 'No description' }; const todoList: TodoList = { id: '', name: data.name, items: [item] }; // .push() also creates a new unique key, which can be accessed with ref.key let ref: Reference = this.todoLists.push(); ref.set(todoList) .then( () => this.presentToast('List succesfuly added')) .catch(err => this.presentToast('Something wrong happened: ' + err));} (adsbygoogle = window.adsbygoogle || []).push({});
10-06 11:59