类型“typeof firestore”没有调用签名 nativescript 7 @nativescript/firebase 插件

问题描述

我有一个项目,在该项目中我将 nativescript 与 Angular 结合使用,并希望为后端实现 Firebase。我按照包文档中的说明进行操作,firebase.init() 可以正常工作。但是当我想像这里一样使用 firestore 时:

const usernameCollection = firebase.firestore().collection("testUsernames");

我收到错误

此表达式不可调用。类型“typeof firestore”没有调用签名。

我像这样导入模块:

import { firebase } from "@nativescript/firebase";

解决方法

您当前的导入引入了静态类型和类,但没有引入模块本身。

要引入模块,您需要将 /app 添加到路径末尾作为(较差)shown here

无论您在哪里看到 "nativescript-plugin-firebase",都将其替换为 "@nativescript/firebase"

import * as firebase from "@nativescript/firebase/app";
,

添加以下行:

import * as firebase from "@nativescript/firebase/app";

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...