我正在使用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!');
}
});
答案 0 :(得分:2)
.info/connected
路径仅存在于Firebase数据的顶层。您无法从子节点访问它。
所以改变
new Firebase("https://123654789.firebaseio.com/123654/.info/connected")
要
new Firebase("https://123654789.firebaseio.com/.info/connected")
错误信息将消失。