Firestore 中的实时侦听器抛出类型错误
Realtime listener in Firestore throws type error
我正在尝试在 Firebase 9 中为我的 Vue 项目附加一个实时监听器。这是我的功能:
function updateProfiles() {
const q = query(collection(db, "candidateprofiles"), where("useridprimary", "==", store.state.currentUserId));
onSnapshot(q, (snapshot) => {
let profiles = []
snapshot.docs.forEach((doc) => {
profiles.push({...doc.data(), id: doc.id })
})
console.log('success: ' + profiles)
})
}
它不起作用,我收到以下错误:
“未捕获(承诺)FirebaseError:预期类型 'Ac',但它是:自定义 cn 对象”
感谢您的帮助!
我解决了,我混合了从 firebase/firestore 和 firebase/firestore/lite 导入的 firestore。后者不适用于 onSnapshot
我正在尝试在 Firebase 9 中为我的 Vue 项目附加一个实时监听器。这是我的功能:
function updateProfiles() {
const q = query(collection(db, "candidateprofiles"), where("useridprimary", "==", store.state.currentUserId));
onSnapshot(q, (snapshot) => {
let profiles = []
snapshot.docs.forEach((doc) => {
profiles.push({...doc.data(), id: doc.id })
})
console.log('success: ' + profiles)
})
}
它不起作用,我收到以下错误:
“未捕获(承诺)FirebaseError:预期类型 'Ac',但它是:自定义 cn 对象”
感谢您的帮助!
我解决了,我混合了从 firebase/firestore 和 firebase/firestore/lite 导入的 firestore。后者不适用于 onSnapshot