【发布时间】:2018-11-18 01:09:11
【问题描述】:
我在 Ionic/Angular 中的打字稿代码出现错误。错误输出为:
[22:55:09] 打字稿:C:/xampp/htdocs/project x/anonymous-social/src/pages/chat/chat.ts,行:103 预期有 1 个参数,但得到了 0 个。
L102: if(!this.isUserThreadEmpty) {
L103: let threadKey = this.database.list('users/'+this.userData.uid+'/threads/'+this.recipient).push().key;
L104: 让收件人数据 = {
我不知道为什么会这样,我猜push() 需要一个参数,但是我在网上看到的关于如何在 firebase 中获得key 的所有stackoverflow 答案都指向了这个解决方案,所以我不是确定发生了什么。
实际代码为:
if(!this.isUserThreadEmpty) {
let threadKey = this.database.list('users/'+this.userData.uid+'/threads/'+this.recipient).push().key;
let recipientData = {
recipient: this.recipient,
threadId: threadKey,
displayName: this.displayName,
}
有什么想法吗?我需要将key 传递给recipientData...我做错了什么?
【问题讨论】:
-
I would guess that push() needs an argument- 是的,确实如此...all the stackoverflow answers I saw online...你能链接到在这样的数组上使用.push()的那个吗? -
@JaromandaX 这个例如:stackoverflow.com/questions/38768576/…
-
@JaromandaX 官方文档:firebase.google.com/docs/database/admin/…
-
哦,所以
this.database.list('users/'+this.userData.uid+'/threads/'+this.recipient)不是数组 - 抱歉,我的错
标签: typescript firebase firebase-realtime-database angularfire2