所以我的商店里有这个突变:

DELETE_POST: (state, index) => {
  state.Posts.splice(index, 1);
}

我也有这个动作:

delete({ commit, state }, index) {
  commit('DELETE_POST', index);
}

此操作基本上删除了通过vue-apollo返回的帖子数组中的帖子 .

在我的Vue组件中调度操作 this.$store.dispatch('Posts/delete', index);

导致 TypeError: 0 is read-only 错误

这是商店的状态:

export const state = () => ({
  Posts: [] 
})

以及负责设置帖子的变异:

export const mutations = {
  SET_POSTS: (state, posts) => {
    state.Posts = posts;
  },

以下是我们如何使用apollo客户端通过graphql查询填充商店

export const actions = {
  async get({ commit, state }, params) {
    let client = this.app.apolloProvider.defaultClient;
    let { data: response } = await client.query({
      query: GetPostsQuery
      variables: {
        id: parseInt(params.id) || null,
        description: params.description || '',
        categoryId: params.categoryId || null,
      },
      fetchPolicy: 'network-only'
    });
    let postsDetails = response.Posts.get;
    if (postsDetails.status_code !== 200) return false;
      commit('SET_POSTS', postsDetails.data);
    return postsDetails.data;
  },

这是一个vue-apollo问题吗?如果是这样我怎么可能修改状态呢?