当action使用promise时,indexOf拒绝在值突变中工作
indexOf refuses to work inside vue mutation when action is using promise
当我使用带有承诺的行动时,我确实得到了一些问题,使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不是一个函数,有人知道为什么是这样吗?
我真蠢,重新分配了state。items数组到对象的代码和indexOf函数消失
相关文章:
- Javascript:selenium Web驱动程序isDisplayed()不工作
- jQuery UI自动完成突然停止工作
- AngularJS UI路由器不能像ng路由器那样工作
- HTML5音频加载和播放获胜'我不能在iPad上工作
- JavaScript打印功能使日历停止工作
- Javascript.getHours()工作不正常
- 为什么这在IE中的工作方式与在Firefox中不同
- 视频HTML没有'无法在Internet Explorer 11上工作
- 扩展移相器按钮类不工作
- Firebase迁移-简单的Firebase.set没有'不再工作了——旧的还是新的
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- 正在尝试使用if和else添加类,但无法正常工作
- Jquery FadeIn FadeOut 只工作一次
- Foreach无法在Typescript中工作
- 另一个ajax调用中的Jquery ajax调用在for循环中没有按预期工作
- 为什么不是't窗口.恢复正常工作吗?(javascript/jquery)
- JS可以在Chrome中工作,但不能在Firefox中工作
- ajaxToolkit PopupControlExtender不工作.过时的
- HTML标记在脚本标记中工作
- 当action使用promise时,indexOf拒绝在值突变中工作