0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Vuex】Stateを丸ごと置き換える

Last updated at Posted at 2020-08-11

Good:ok_hand:

Object.assignを使って置換できます。

mutation.js
export default {
  replaceState (state, { value }) {
    Object.assign(state, value)
  }
}

Bad:thumbsdown:

Vuexでstateを置き換えたいときに、
以下のように代入してもうまく動作しません。


export default {
  replaceState (state, { value }) {
    staet = value
  }
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?