【发布时间】:2018-08-18 08:34:11
【问题描述】:
我在 firebase 上遇到此错误(使用 vue.js):
第一次一切顺利,我可以根据需要多次运行以下功能。
addSpace: function (newSpace) {
let userId = firebaseApp.auth().currentUser.uid;
const key = spacesRef.push().key; // creating the key once
console.log(key);
spacesRef.child(key).update(this.newSpace); }
但是,如果当我运行另一个函数(参见下面的函数 AddDept)时,addSpace 函数会抛出错误:
addDept: function(space, dept, newDept, event) {
this.newSpace = space;//get current space
const deptKey = deptsRef.push().key; // create Dept Key
let spaceKey = space['.key'];
console.log(spaceKey)
var deptNode = spacesRef.child(spaceKey).child("hasDepts");
deptNode.child(deptKey).set(true);
deptsRef.child(deptKey).set(this.newDept);
deptsRef.child(deptKey).child("spaceName").set(space.name);
deptsRef.child(deptKey).child("spaceKey").set(spaceKey);
this.newDept.name = '';
this.newDept.comments = '';
this.newSpaceKey= '';
},
这里到底发生了什么?
Error: Reference.update failed: First argument contains an invalid key
(.key) in path /.key. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"
我已经控制台记录了所有参数,它们看起来很正常。我也尝试过对参数进行字符串化,但没有成功。 感谢所有帮助。
【问题讨论】:
-
我认为它在说
'.key'.
标签: javascript firebase vue.js