gpt4 book ai didi

javascript - Angular 6 GeoFire 初始化 GeoFire 不是构造函数

转载 作者:行者123 更新时间:2023-11-30 09:21:17 25 4
gpt4 key购买 nike

enter image description here我在 Angular 6 上初始化 GeoFire 时遇到问题。当我尝试初始化 GeoFire 时,

geofire__WEBPACK_IMPORTED_MODULE_2__ is not a constructor

抛出错误。

下面是我的依赖和代码。

"@angular": "6.0.2",
"firebase": "5.0.3",
"geofire": "4.1.2",
"angularfire2": "5.0.0-rc.9"
"typescript": "2.7.2"

import * as GeoFire from 'geofire';
import * as firebase from 'firebase/app';
[![enter image description here][1]][1]
@Component({
selector: 'app-near-by-page',
templateUrl: './near-by-page.component.html',
styleUrls: ['./near-by-page.component.scss']
})
export class NearByPageComponent extends PageComponent {
constructor() {
super();

// Generate a random Firebase location
const firebaseRef = firebase.database().ref().child('locations');

// Create a new GeoFire instance at the random Firebase location
const geoFire = new GeoFire(firebaseRef);
const geoQuery = geoFire.query({
center: [51.294, -0.245],
radius: 1
});
}

}

最佳答案

导入

const geofire = require('geofire');

用法

const geoFireInstance = new geofire.GeoFire(ref);

来源:https://github.com/firebase/geofire-js/issues/173#issuecomment-487026534

关于javascript - Angular 6 GeoFire 初始化 GeoFire 不是构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51455816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com