我将大部分时间都用在Java和C ++等语言上,但是我想尝试使用JavaScript。我试图完成的是一种通过传递的变量的值设置父节点名称的方法。我正在使用Firebase,如果这在此代码中有所作为,但我认为不会。
var parent_node_name = "EPLU200";
var onComplete = function(error) {
if (error) {
console.log('Synchronization failed');
} else {
console.log('Synchronization succeeded');
}
};
// update adds the data without replacing all of the other nodes
myFirebaseRef.update({
parent_node_name: { // trying to change this part to not save as "parent_node_name"
id2: "1175", // but instead as "EPLU200"
...
}
}, onComplete);
该操作可以很好地保存到我的Firebase服务器,但是问题是传递变量的实际值,而不是读取变量名。
JavaScript中有什么解决方法吗?我尝试搜索它,但不知道该怎么称呼。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句