问题描述
我有一个项目,在该项目中我将 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";