FireStore的get()和onSnapshot()函数返回该错误。到目前为止,我已经在计算机上的不同浏览器上进行了测试,Chrome可以正常运行,但是IE,Edge和Firefox都返回相同的错误。 但是,在我同事的计算机上,即使Chrome也返回相同的错误。 我花了半天,但没有运气。 我不确定这是浏览器设置还是其他设置。
var config = {
apiKey: "xxxxxx",
authDomain: "xxxxxx",
databaseURL: "xxxxxx",
projectId: "xxxxxx",
storageBucket: "xxxxxx",
messagingSenderId: "xxxxxx"
};
firebase.initializeApp(config);
console.log('firebase initialized');
// Initialize Cloud Firestore through Firebase
var firestoreDB = firebase.firestore();
const settings = {/* your settings... */ timestampsInSnapshots: true};
firestoreDB.settings(settings);
console.log('Cloud Firestore initialized');
var docRef = firestoreDB.collection("cities").doc("SF");
docRef.onSnapshot(function(doc) { <=== ERROR =====
console.log("Current data: ", doc.data());
});