javascript - TypeError:无法读取未定义的属性“FieldValue”
问题描述
19 | event.preventDefault();
20 | db.collection('todos').add({
21 | todo:input,
22 | timestamp: firebase.firestore.FieldValue.serverTimestamp()
23 | });
24 |
25 | setInput("");
每当我尝试运行此代码时,它都会显示类型错误。这样我就无法将数据推送到 Firebase
解决方案
确保您具有正确的timestamp
值,或者如果您不需要它们,请不要传递时间戳。尝试将此 json 传递给 todos 集合:
{
todo:input,
timestamp: firebase.firestore.FieldValue.serverTimestamp() || null
}
通过登录并尝试确保您在FieldValue
里面firebase.firestore
console.log(firebase.firestore)
console.log(Object.keys(firebase.firestore))
推荐阅读
- c - 为什么char值增加3?
- java - 如何在 onClick 事件和 Activity 更改后将 textView 设置为可见?
- azure - 跟踪 Azure DevOps 构建活动
- ruby-on-rails - 将日期字符串转换为时区特定格式
- email - google 应用程序脚本:file.setOwner() 未在 Google Drive 中转移所有权
- c# - 如何从查看 http post 将列表模型传递给控制器
- google-apps-script - 谷歌表格以模态嵌入谷歌表单
- c# - MVVM - 如何从父 ViewModel 引用子 ViewModel(ViewModel 在其视图中创建)?
- javascript - How to rotate an arc in canvas using context?
- java - 如果java中的字符串是不可变的,为什么我可以这样做?