将数据传递到nuxt提取,存储分派不起作用

问题描述 投票:0回答:1

我正在尝试传递一个参数来存储。$ dispatch,但是如果我从数据中调用数据,它说该数据是未定义的。

为什么这不起作用:

data () {
  return {
    year: '2019'
  }
},
async fetch({store}) {
    await store.dispatch('posts/fetchAll', this.year)
},

但是这样做:

async fetch({store}) {
    await store.dispatch('posts/fetchAll', '2019')
},

我正在使用veux和nuxt。

javascript vue.js fetch vuex nuxt
1个回答
0
投票

文档说:

© www.soinside.com 2019 - 2024. All rights reserved.