【发布时间】:2020-12-01 10:26:53
【问题描述】:
我正在使用 ionic 5 和 firebase 应用程序创建基于用户的内容和按钮显示。 我正在发布并在我的应用程序中实现它。
我和使用:
"firebase": "^8.1.1","@angular/fire": "^6.1.3",
现在auth() 和firestore() 出现错误
auth 错误是:“typeof 导入”类型上不存在属性“auth” (TS-2339) 并且 firebase 错误是 - 属性“firestore”不存在 关于类型'typeof import
import { Component, OnInit } from "@angular/core";
import * as firebase from "firebase/app";
import "firebase/auth";
import "firebase/firestore";
@Component({
selector: "app-places",
templateUrl: "./posts.page.html",
styleUrls: ["./posts.page.scss"],
})
export class PlacesPage implements OnInit {
constructor() {}
//firestore = firebase.firestore();
public isAdmin = false;
ngOnInit() {
//Property 'auth' does not exist on type 'typeof import
firebase.auth().onAuthStateChanged((user) => {
if (user) {
firebase
.firestore() //Property 'firestore' does not exist on type 'typeof import
.doc(`s/${user.id}`)
.get()
.then((userProfileSnapshot) => {
this.isAdmin = userProfileSnapshot.data().isAdmin;
});
}
});
}
}
【问题讨论】:
-
请编辑问题以显示您正在使用的 firebase 模块的版本。它将在您的 package.json 中。
-
@DougStevenson 我更新了问题。谢谢
标签: javascript angular firebase ionic-framework google-cloud-firestore