当我使用带有承诺的动作时,我确实遇到了一些问题,让 vuex 突变中的 indexOf 起作用。这是我的行动
export const deleteItem = ({commit}, item) => {
return new Promise((resolve, reject) => {
Vue.http.delete(item.url, item)
.then(response => {
commit(types.DELETE_ITEM, {response, item})
resolve(response)
})
.catch(error => {
commit(types.ERROR, error)
reject(error)
})
})
}
这是我的突变
[types.DELETE_ITEM](state, {response, item}) {
state.notifications = {
display: true,
type: 'success',
ok: response.ok,
status: response.status,
statusText: response.statusText,
body: response.body
}
state.items.splice(state.items.indexOf(item), 1)
}
我收到一个错误 indexOf is not a function 有人知道为什么吗?