【发布时间】:2019-03-17 01:36:13
【问题描述】:
我需要你的帮助...
我无法将带有地理数据的对象保存到我的 Firestore(来自 vue 应用程序)。
没有地理点的对象被保存到 Firestore,但是当我尝试使用 GeoPoint 类添加文档时,我收到以下错误:
Uncaught TypeError: this.$db.GeoPoint is not a constructor
at VueComponent.addProperty (index.2ad219460d4ddfd5635c.hot-update.js:226)
at click (index.3901b064c6620cd7292b.hot-update.js:149)
at invoker (commons.app.js:10574)
at HTMLButtonElement.fn._withTask.fn._withTask [...]
'This.$db' 是对 firebase.firestore() 对象的引用 -> 因为它可以在没有 GeoPoints 的情况下工作,所以这个导入/注入应该是正确的(我也尝试过直接导入 firebase-instance,但没有成功.
我的函数如下所示:
this.$db.collection("property").add({
meta_data:this.meta_data,
address: this.address,
location: new this.$db.GeoPoint(8.241, 46.838)
})
.then(function(docRef) {
console.log("Document written with ID: ", docRef.id);
})
.catch(function(error) {
console.error("Error adding document: ", error);
});
我的依赖:
"dependencies": {
"@mapbox/mapbox-gl-geocoder": "^2.3.0",
"@mapbox/mapbox-sdk": "^0.4.1",
"firebase": "^5.5.3",
"geojson": "^0.5.0",
"gsap": "^2.0.2",
"mapbox-gl": "^0.49.0",
"nuxt": "^2.1.0",
"vuefire": "^1.4.5",
"vuetify": "^1.2.9"
},
我错过了什么吗?任何帮助表示赞赏!非常感谢
【问题讨论】:
标签: firebase vue.js google-cloud-firestore nuxt.js