簡體   English   中英

Firestore 中的實時偵聽器拋出類型錯誤

[英]Realtime listener in Firestore throws type error

我正在嘗試在 Firebase 9 中為我的 Vue 項目附加一個實時監聽器。 這是我的 function:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM