【发布时间】:2020-10-29 20:44:19
【问题描述】:
不断收到未定义的查询...谁能告诉我如何使用 Nuxtjs 在 Vuex 商店中访问 this.$apollo.query?
import gqlGetAllTags from '~/apollo/queries/gqlGetAllTags.gql'
@Module({
stateFactory: true,
namespaced: true,
name: 'products',
})
export default class Products extends VuexModule {
product: Array<object> = []
@Mutation
GET_PRODUCT(product: Array<object>) {
this.product = product
}
@Action({ rawError: true })
async getProduct() {
const collection = await this.$apollo.query({
query: gqlGetAllTags,
variables: {
handle: 'nirvana',
},
})
this.context.commit('GET_PRODUCT', collection)
}
}
【问题讨论】:
标签: javascript vue.js vuejs2 vuex nuxtjs