【发布时间】:2022-08-22 23:28:55
【问题描述】:
我的 js 文件在 DOM 中正确输入,我在 firebase.js 文件中初始化了 firebase。为什么我收到 TypeError \'collection(...).doc is not a function\' - 集合查询直接取自 firebase 文档站点,我不明白这怎么可能是类型错误。有什么想法吗?
import { app } from \"./firebase\";
import { getFirestore, doc, collection } from \"firebase/firestore\";
const db = getFirestore(app);
// get data
const docRef = collection(db, \'posts\').doc(\'ARt1ctrEjweKEd4gmgCr\');
await docRef.get();
if (!doc.exists) {
console.log(\'No such document!\');
} else {
console.log(\'Document data:\', doc.data());
}
标签: javascript firebase google-cloud-firestore