0

約束でアクションを使用すると、 vex ミューテーション内の 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というエラーが表示されますが、それはなぜですか?

4

1 に答える 1

0

コード内で state.items 配列をオブジェクトに再割り当てするほど愚かで、 indexOf 関数が消えました。

于 2016-11-15T16:33:33.423 に答える