小编SSo*_*eim的帖子

如何在 Firebase Cloud 中将变量值设置为字段名称。网页/HTML

我正在尝试将我在表单中输入的数据设置为 Firebase 中的字段名称。

它在第 3 行$("#blogUID").val()(博客/blogUID 集合)中运行良好。但是,当我尝试在 Stats/Blogs 集合(第 10 行)中设置字段名称时,出现以下错误:

error.ts:166 Uncaught FirebaseError: Function CollectionReference.doc() requires its first argument to be of type non-empty string, but it was: undefined
    at new ui (https://www.gstatic.com/firebasejs/7.17.1/firebase-firestore.js:1:52471)
    at Vh (https://www.gstatic.com/firebasejs/7.17.1/firebase-firestore.js:1:164122)
    at kh (https://www.gstatic.com/firebasejs/7.17.1/firebase-firestore.js:1:163328)
    at _d.doc (https://www.gstatic.com/firebasejs/7.17.1/firebase-firestore.js:1:280502)
    at HTMLButtonElement.<anonymous> (http://localhost:8080/TeamSolheim_Page1.html:251:36)
    at HTMLButtonElement.dispatch (https://code.jquery.com/jquery-3.5.1.min.js:2:43090)
    at HTMLButtonElement.v.handle (https://code.jquery.com/jquery-3.5.1.min.js:2:41074)
Run Code Online (Sandbox Code Playgroud)
1    $("#blog-submit-button").click(function(){
2        // Add a new document in collection
3        // db.collection("Blogs").doc($("#blogUID").val()).set({
4        //     blogDate:  $("#blogDate").val(),
5        //     blogLink:  $("#blogLink").val(),
6        //     blogTitle: $("#blogTitle").val(),
7 …
Run Code Online (Sandbox Code Playgroud)

html javascript firebase google-cloud-firestore

2
推荐指数
1
解决办法
614
查看次数