首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >vuexfire firestoreAction,与参数绑定

vuexfire firestoreAction,与参数绑定
EN

Stack Overflow用户
提问于 2019-06-24 01:56:12
回答 1查看 630关注 0票数 3

我正在尝试将模块的存储区绑定到文档

代码语言:javascript
复制
import Vue from 'vue'
import { db } from '../my-firebase/db'
import { firestoreAction } from 'vuexfire'

export const user = {
   ...
    actions: {
        logOutUser: ({ commit }) => {
            commit('logOutUser')
        },
        logInUser: ({ dispatch, commit }, userInfo) => {
            let dbRef = db.collection('users').doc(userInfo.uid)
            dbRef.update({ authInfo: userInfo })
                .then(() => {
                    commit('logInUser', userInfo)
                })
            dispatch('bindFirebaseUser', dbRef)
        },
        bindFirebaseUser: (context, userRef) => {
            console.log('Running dispatch BindFirebaseUser')
            return firestoreAction(({ bindFirestoreRef }) => {
                // return the promise returned by `bindFirestoreRef`
                console.log('userRef:')
                console.log(userRef)
                return bindFirestoreRef('firebaseData', userRef)
            })
        }
    }
}

这不管用。如何使用参数userRef进行bindFirestoreRef?它似乎没有绑定,尽管我可以正确地写入firestore,所以我假设我的db设置正确。

它只是不会给出任何形式的错误,但是如果它绑定了,它应该用我错误的数据填充我的存储,不是吗?

EN

回答 1

Stack Overflow用户

发布于 2020-04-07 03:52:07

可以将引用作为第二个参数传递给firestoreAction

代码语言:javascript
复制
bindFirebaseUser: firestoreAction(({ bindFirestoreRef }, userRef) => {
   return bindFirestoreRef('firebaseData', userRef)
})
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56726471

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档