从Vuex商店使用NUXT中的vue-apollo来访问this.$ apollo吗? [英] Access to this.$apollo from Vuex store with vue-apollo in NUXT?

查看:84
本文介绍了从Vuex商店使用NUXT中的vue-apollo来访问this.$ apollo吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将来自登录操作的用户存储在vuex存储中.但是无法访问 this.$ apollo .

I want to store the user that comes from the login on an action in the vuex store. But there is no access to this.$apollo.

export const actions = {
  UPSERT_USER({ commit }, { authUser, claims }) {
     this.$apollo
        .mutate({
          mutation: UPSERT_USER_MUTATION,
          variables: {
            id: user.uid,
            email: user.email,
            name: user.name,
            picture: user.picture,
          },
        })
    }

谢谢!

推荐答案

您应该可以这样访问它:

You should be able to access it like this:

export default {
  actions: {
    foo (store, payload) {
      let client = this.app.apolloProvider.defaultClient
    }
  }
}

查看 https://github.com/nuxt-community/apollo-module

这篇关于从Vuex商店使用NUXT中的vue-apollo来访问this.$ apollo吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆