Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 返回空文档数组的子集合的querySnapshot_Firebase_Vue.js_Google Cloud Firestore - Fatal编程技术网

Firebase 返回空文档数组的子集合的querySnapshot

Firebase 返回空文档数组的子集合的querySnapshot,firebase,vue.js,google-cloud-firestore,Firebase,Vue.js,Google Cloud Firestore,检索Firestore子集合中的文档时出错。querySnapshot返回一个空数组,其中应该包含文档。下面是我的代码和Firestore设置。ref定义为 var ref=db.collection(“LiveRooms”).doc(此.roomCode) 请编辑问题,在此处对所有变量进行硬编码,尤其是this.roomCode,我们无法看到,也不知道它是否与图片中显示的内容匹配。另外,请显示您的程序的日志输出,以便我们可以看到它是如何执行的,并确保指出与您期望的不同之处。您能否在代码中显示您

检索Firestore子集合中的文档时出错。querySnapshot返回一个空数组,其中应该包含文档。下面是我的代码和Firestore设置。ref定义为
var ref=db.collection(“LiveRooms”).doc(此.roomCode)


请编辑问题,在此处对所有变量进行硬编码,尤其是
this.roomCode
,我们无法看到,也不知道它是否与图片中显示的内容匹配。另外,请显示您的程序的日志输出,以便我们可以看到它是如何执行的,并确保指出与您期望的不同之处。您能否在代码中显示您在哪里执行
var ref=…
?通过执行
this.ref
通常意味着
ref
是Vue.js的一个属性,但您似乎没有为此
ref
属性指定值。我们希望看到一些东西,比如
this.ref=db.collection(“LiveRooms”).doc(this.roomCode)在您的代码中。另外,您可以在承诺链中添加一个
catch()
块:
this.ref.collection(“Songs”).get().then(…).catch(error=>{console.log(error)})
请编辑问题,将所有变量硬编码到这里,尤其是
this.roomCode
,我们看不到,也不知道它是否与图片中显示的内容匹配。另外,请显示您的程序的日志输出,以便我们可以看到它是如何执行的,并确保指出与您期望的不同之处。您能否在代码中显示您在哪里执行
var ref=…
?通过执行
this.ref
通常意味着
ref
是Vue.js的一个属性,但您似乎没有为此
ref
属性指定值。我们希望看到一些东西,比如
this.ref=db.collection(“LiveRooms”).doc(this.roomCode)在您的代码中。另外,您可以向承诺链添加
catch()
块:
this.ref.collection(“Songs”).get()。然后(…).catch(error=>{console.log(error)})
test() {
      console.log("Test invoked");
      this.ref
        .collection("Songs")
        .get()
        .then(function (querySnapshot) {
          console.log(querySnapshot)
          querySnapshot.forEach(function (doc) {
            console.log("doc")
            // doc.data() is never undefined for query doc snapshots
            console.log(doc.id, " => ", doc.data());
          });
        });
    },