我想知道我們如何在具有動態元素名稱的地圖中存盤元素(地圖)。我嘗試了以下
var activequestionid = "12201"
var aqid = "answers." activequestionid
await updateDoc((doc(db, "tests", testid), {
[`${aqid}`]: {ans:ans,type:type,time:serverTimestamp()}
}))
var activequestionid = "12201"
var aqid = "answers." activequestionid
await updateDoc((doc(db, "tests", testid), {
[aqid]: {ans:ans,type:type,time:serverTimestamp()}
}))
我的地圖也如下:
testid(document)
answers(map)
12201(map)
但是兩者都給出了相同的錯誤:Expected type 'Pc', but it was: a custom Object object
感謝您對此問題的任何幫助!
uj5u.com熱心網友回復:
該updateDoc()函式采用 2 個引數 - DocumentReference和資料。你有()他們兩個,所以本質上這是1個引數。嘗試洗掉它們:
var activequestionid = "12201"
var aqid = "answers." activequestionid
await updateDoc(
doc(db, "tests", testid), {
[aqid]: {
ans: ans,
type: type,
time: serverTimestamp()
}
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/454831.html
標籤:javascript 火力基地 谷歌云火库
