nativescript-vue / firebase.query中的错误:ReferenceError:找不到变量:FIRDatabase

时间:2019-12-22 20:59:18

标签: firebase firebase-realtime-database nativescript-vue

我已使用我的应用在Firebase中成功进行了身份验证。 我已经导入了一个用户集合,并想查询这些数据。

我在方法中的代码:

import firebase from "nativescript-plugin-firebase";
...

getData(){

                var onQueryEvent = function(result) {

                    if (!result.error) {
                        console.log("Event type: " + result.type);
                        console.log("Key: " + result.key);
                        console.log("Value: " + JSON.stringify(result.value)); // a JSON object
                        console.log("Children: " + JSON.stringify(result.children)); // an array, added in plugin v 8.0.0
                    }
                };

                    firebase.query(
                    onQueryEvent,
                    "/Users",
                    {

                        singleEvent: true

                    }
                );

            }   // get data  

firebase中的数据: enter image description here

现在我得到了错误:  “ firebase.query中的错误:ReferenceError:找不到变量:FIRDatabase”

我已经完成了Eddy Verbruggen的所有建议,但没有机会,这是行不通的。

THX提前获得帮助。

编辑:这是解决方案:

import firestore from "nativescript-plugin-firebase/app/firestore";

const db = firebase.firestore;

  getData(){


                db.collection("Users").get().then(function(querySnapshot) {
                querySnapshot.forEach(function(doc) {
                // doc.data() is never undefined for query doc snapshots
                console.log(doc.id, " => ", doc.data());
                  });
             });

和数据:

  

控制台日志文件:///app/components/Home.vue:55:0:'K100''=>'{   电子邮件:“ Andy.Zniston@mail.com”,名字:“ Zniston”,名称:“ Andy”}   控制台日志文件:///app/components/Home.vue:55:0:'K1000''=>'{   电子邮件:“ Armando.Zemario@mail.com”,名字:“ Zemario”,名称:   'Armando'}

0 个答案:

没有答案