新Firebase失败:第一个参数必须是有效的firebase网址,路径不能包含"。","#"," $" ," [",或"]"

时间:2015-07-20 14:08:48

标签: javascript firebase

我正在使用Firebase检查状态,但控制台会抛出以下错误:

New Firebase failed: First argument must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".

以下是代码:

new Firebase("https://123654789.firebaseio.com/123654/.info/connected").on('value', function(connectedSnap) {
  console.log(connectedSnap.val());
  if (connectedSnap.val() === true) {
    alert('I am connected!');
  } else {
    /* we're disconnected! */
    alert('not connected!');
  }
});

1 个答案:

答案 0 :(得分:2)

.info/connected路径仅存在于Firebase数据的顶层。您无法从子节点访问它。

所以改变

new Firebase("https://123654789.firebaseio.com/123654/.info/connected")

new Firebase("https://123654789.firebaseio.com/.info/connected")

错误信息将消失。