由于某种原因,控制台会抛出错误 "TypeError: n.indexOf is not a function",我不太理解为什么会发生这种情况。我正在使用Firestore和Firebase v9模块化版本,基本上是一个在Firestore数据库中创建类别,并在类别内创建测试任务的功能。
以下是完整的错误信息:
TypeError: n.indexOf is not a function
at Function.fromString (index.esm2017.js:1032)
at va (index.esm2017.js:14990)
at App.jsx:48
错误信息中的第48行是:
const taskRef = doc(collection(db, "categorias"), where("uid", "==", currentUser), newDocRef.id)
这是我的代码 :)
const currentUser = '1234'
const crearCategoria = useCallback(async() => {
try {
const newDocRef = doc(collection(db, "categorias"));
await setDoc(newDocRef, {
name: categoryName,
uid: currentUser,
projectId: newDocRef.id
})
const taskRef = doc(collection(db, "categorias"), where("uid", "==", currentUser), newDocRef.id)
await setDoc(taskRef, {
name: 'prueba',
uid: currentUser,
projectId: newDocRef.id
})
} catch (error) {
console.log(error)
}
})