【问题标题】:How to pass dynamic data from form into Firestore using Cordova?如何使用 Cordova 将动态数据从表单传递到 Firestore?
【发布时间】:2020-11-25 20:56:37
【问题描述】:

我有一个表单,我想将表单输入值传递到这里。如何根据表单输入值动态填充“旧金山”?

我已尝试创建变量并使用变量填充字段,但收到一条错误消息,提示

error.ts:166 未捕获的 FirebaseError:使用无效数据调用函数 DocumentReference.set()。不支持的字段值:未定义(在文档事件/RNiEJ9nUxVO1IGFr0TL5 中的字段 eventName 中找到)

参考链接:https://firebase.google.com/docs/firestore/query-data/get-data#web

【问题讨论】:

  • 为了完全清楚这一点,您想将表单上加载的数据发布到 Firestore 还是要在表单中加载 Firestore 数据?
  • @JoséSoní 我想将表单上加载的数据上传到 Firestore
  • 我编辑了答案,将代码保留为代码 sn-p,在 Stack Overflow 中,最好将代码共享为 sn-p 而不是图像
  • 谢谢你,@JoséSoní

标签: firebase cordova google-cloud-firestore cordova-2.0.0


【解决方案1】:

变量值未定义。这应该可以解决它。

db.collection("events").add({
    eventName: document.getElementById('eName').value.toString(),
    organiserName: document.getElementById('oName').value.toString(),
    eventDescription: document.getElementById('oDesc').value.toString(),
    eDateTime: document.getElementById('eDateTime').value.toString(),
    eType: document.getElementById('eType').value.toString(),
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-14
    • 2018-04-05
    • 1970-01-01
    • 2020-09-03
    • 2019-08-20
    • 2020-10-23
    • 2023-03-14
    相关资源
    最近更新 更多