错误:
我不知道问题是什么,为什么我会收到此错误?
function downloa2323d() {
console.log("Trying to download")
get(child(database, `design-tournament/`)).then((snapshot) => {
if (snapshot.exists()) {
let jsonData = snapshot.val();
function download(content, fileName, contentType) {
const a = document.createElement("a");
const file = new Blob([content], { type: "application/json" });
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
function onDownload(){
console.log(jsonData)
download(jsonData, "design-tournament-game.json", "text/plain");
}
onDownload()
} else {
console.log("No data available");
}
}).catch((error) => {
console.error(error);
});
}
document.getElementById("exportGame").addEventListener('click', downloa2323d )
错误行:745是代码中从firebase获取子数据库
import { getDatabase, ref, child, get, push, update, onValue } from "https://www.gstatic.com/firebasejs/10.0.0/firebase-database.js";
const app2 = initializeApp(firebaseConfig2, "server");
const database = getDatabase(app2);
我修好了!我忘了添加 ref()。阅读文档后我注意到了
也许如果您遇到此问题,请尝试添加 ref( 数据库 ) 而不仅仅是数据库