作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的代码:
var pushRef = currentAssignment.child('answers').push().catch(e => console.log('push', e));
pushRef.set({
// downloadURL: downURL,
textAnswer: textAnswer,
date: this.generateDate(),
seen: false,
// firebaseKey: pushRef.getKey(),
workKey: this.props.questionId
})
当我尝试运行它时,出现此错误:pushRef.set()
,但根据this part of the documentation在我看来,我所做的一切都是一样的。以下是 Google 的推送指令示例:
var postsRef = ref.child("posts");
var newPostRef = postsRef.push();
newPostRef
.set({
author: "gracehop",
title: "Announcing COBOL, a New Programming Language"
});
// we can also chain the two calls together
postsRef
.push()
.set({
author: "alanisawesome",
title: "The Turing Machine"
});
那么我错过了什么?
最佳答案
通过在 push()
后面添加 .catch(e => console.log('push', e))
,您可以将其从 firebase 数据库引用更改为某些内容别的。因此删除它可以解决这个问题。
据我所知,调用 push()
(不带参数)永远不会生成错误,它只会生成一个 Firebase 引用(唯一 key )客户端。
关于javascript - PushRef.set() 不是函数,Firebase 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50839819/
这是我的代码: var pushRef = currentAssignment.child('answers').push().catch(e => console.log('push', e));
我是一名优秀的程序员,十分优秀!