【问题标题】:Can't initialize a geofire object in typescript无法在打字稿中初始化 geofire 对象
【发布时间】:2017-09-06 16:54:30
【问题描述】:

我正在使用ionic-framework version 2typescript

上周我在我的应用中集成了 Firebase,效果很好。现在我也想集成 geofire,但我无法初始化 geofire 对象的实例。

我的 MainSearchPage 类:

import { Component, Inject } from '@angular/core';
import { AngularFire, FirebaseListObservable, FirebaseApp } from 'angularfire2';
import { GeoFire } from 'geofire';

constructor(public af: AngularFire, @Inject(FirebaseApp) firebaseApp: firebase.app.App) {
    var firebaseRef = firebaseApp.database().ref();
    var geofire = new GeoFire(firebaseRef);
}

但我总是收到以下错误:

./MainSearchPage 类 MainSearchPage_Host 中的错误 - 由以下原因引起:WEBPACK_IMPORTED_MODULE_7_geofire.GeoFire 不是构造函数

版本:

ionic-app-script 1.3.1,
typescript 2.0.6,
firebase 3.7.5,
angularfire 2.0.0-beta.8,
geofire 4.1.2,

我将不胜感激。

【问题讨论】:

  • 您找到解决方案了吗?我也有同样的问题

标签: typescript firebase ionic2 geofire


【解决方案1】:

尝试像这样导入 Geofire

import * as GeoFire from "geofire";

【讨论】:

  • 欢迎来到stackoverflow!除非您有具体的答案,否则尽量避免在答案中发表评论。请使用下面的评论框,一旦您有足够的声誉,您就可以对任何帖子发表评论。 :)
猜你喜欢
  • 1970-01-01
  • 2020-07-26
  • 2021-07-24
  • 1970-01-01
  • 2021-08-15
  • 1970-01-01
  • 2018-08-14
  • 1970-01-01
  • 2018-06-01
相关资源
最近更新 更多