You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase数据写入问题求助:调用测试函数及Firestore API时出现引用错误

Firebase数据写入问题求助:调用测试函数及Firestore API时出现引用错误

大家好,我最近在做一个小项目——做个网站能把链接发送到手机,手机端会在设定的时间后自动打开这个链接,目前手机端的功能已经跑通了,但卡在数据写入Firebase这一步了😭。我试了各种办法,结果每次都会碰到下面两个错误中的一个:

  • Uncaught ReferenceError: test is not defined
  • Uncaught (in promise) ReferenceError: doc is not defined

我的index.js代码如下(Firebase配置信息已经正确填写,这里就省略具体内容了):

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getDatabase } from "firebase/database";
import { getFirestore, doc, getDoc } from "firebase/firestore";

// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
const firebaseConfig = {
  /* 配置信息已正确填写,此处省略 */
};

目前我有点摸不着头脑,明明已经按文档导入了需要的Firestore API,也想着用test函数来测试数据写入的逻辑,结果两个地方都报了引用错误,有没有大佬能帮我分析下问题出在哪呀?

备注:内容来源于stack exchange,提问作者Para1life

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 14:19:50