Firebase vuexfire+;firestore:如何存储/获取当前页面文档ID?
我的用户可以生成存储在Firebase vuexfire+;firestore:如何存储/获取当前页面文档ID?,firebase,vue.js,google-cloud-firestore,vuexfire,Firebase,Vue.js,Google Cloud Firestore,Vuexfire,我的用户可以生成存储在postsfirestore集合中的帖子。打开单个post页面时,我将在操作中使用vuexfire绑定当前post文档数据: bindPostsRef:firestoreAction(上下文=>{ 返回context.bindFirestoreRef('post',db.collection(“posts”)。其中(“postID”,“postID=”,postID)) }) 由于每个postID都是唯一的,因此它总是返回一个文档,可以使用this.$store.stat
posts
firestore集合中的帖子。打开单个post页面时,我将在操作中使用vuexfire
绑定当前post文档数据:
bindPostsRef:firestoreAction(上下文=>{
返回context.bindFirestoreRef('post',db.collection(“posts”)。其中(“postID”,“postID=”,postID))
})
由于每个postID
都是唯一的,因此它总是返回一个文档,可以使用this.$store.state.post[0]
访问该文档中的数据
然后,我创建了一个deletePost()
操作,以便用户可以删除当前帖子页面后面的文档(如果他们是作者):
deletePost:firestoreAction((上下文,文档ID)=>{
db.collection(“posts”)
.doc(docID)
1.删除()
})
我想知道检索帖子页面当前文档ID的最佳方法是什么。我考虑在文档数据中添加DocumentId本身,以便执行$store.dispatch('deletePost',this.$store.state.post[0].docID)
最好的处理方法是什么