我正在尝试从Google Cloud Firestore加载数据。我可以加载整个数据集,但我无法调用方法并获得单个记录。
Vue-firestore来自https://github.com/gdg-tangier/vue-firestore,但文档未涵盖此内容。
这有效
new Vue({
el : '#app',
...
firestore() {
return {
pages: db.collection('pages')
}
},
这不是
methods: {
showPage: function(id) {
console.log("Getting content for: " + id);
firestore() { return { page : db.collection('pages').where("title", "==", id) } };
console.log(JSON.stringify(this.page));
},
如何将firestore()置于设置的位置之外?
答案 0 :(得分:0)
我误解了firestore()
的作用。
firestore()
不是对正在运行的数据库的调用。类似于建立先前分配给db的连接。
之所以不起作用,是因为已经有一个连接db。