我正在使用Firebase,并且在名为Shout的引用上有一个on(“ value”)事件。首次加载页面时,此shoutRef不存在。当我登陆Firebase时,在shoutRef内部的快照为空。如何避免这种情况?为什么要查看不存在的裁判?
at main.js:127
at EventRegistration.ts:133
at qr (util.ts:586)
at t.raise (EventQueue.ts:171)
at t.raiseQueuedEventsMatchingPredicate_ (EventQueue.ts:123)
at t.raiseEventsForChangedPath (EventQueue.ts:103)
at t.onDataUpdate_ (Repo.ts:277)
at h.onDataPush_ (PersistentConnection.ts:604)
at h.onDataMessage_ (PersistentConnection.ts:597)
at t.onDataMessage_ (Connection.ts:317)
var firebaseData = firebase.database();
var shoutRef = firebaseData.ref("/shout ref");
shoutRef.on("value", (snapshot) => {
var snap = snapshot.val();
//set global variable TODO:May not need in future
console.log(snapshot.val());
});