【发布时间】:2019-02-09 06:25:10
【问题描述】:
那里!我对 Vue.js 和 JavaScript 非常陌生。我正在关注一些 youtube 指南以了解它是如何工作的,但是当我无法将 GeoPoint 添加到我的 Firestore 数据库时,我遇到了这个问题。
这是我所拥有的:
firebaseInit.js
import firebase from 'firebase'
import 'firebase-admin'
import firebaseConfig from './firebaseConfig'
import { scrypt } from 'crypto';
const firebaseApp = firebase.initializeApp(firebaseConfig)
export default firebaseApp.firestore()
和script 相关的.vue 文件:
<script>
import db from "./firebaseInit";
...
greet: function(event) {
db.collection("events_test").add({
name: this.name,
...
location: new admin.firestore.GeoPoint(51.435454, 31.445456),
phone: this.phone
},
originalUrl: this.originalUrl,
createdAt: new Date(),
updatedAt: new Date()
})
.then(docRef =>{
alert(docRef.id)
})
.catch(error => {
alert(error)
});
<script>
new admin.firestore.GeoPoint(51.435454, 31.445456) 这个初始化对我不起作用。以及new GeoPoint(lat,lng) 和firebase.firestore.GeoPoint(lat,lng)。我总是得到ReferenceError,它没有在Vue.Component 中定义。请帮忙。
【问题讨论】:
标签: javascript firebase vue.js google-cloud-firestore