Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

分多个modules引起的问题 #9

Open
suoz opened this issue Mar 29, 2018 · 1 comment
Open

分多个modules引起的问题 #9

suoz opened this issue Mar 29, 2018 · 1 comment

Comments

@suoz
Copy link

suoz commented Mar 29, 2018

比如我定义了一个userModel和otherModel。
在userModel内部state为一个对象{}。
mutations获取参数,当前的state和传递过来的payload。
此时我想改变state这个对象,不能直接去改变参数里面的state。
必须循环一个个遍历state对象的值,payload有相同字段的则覆盖,不同的则添加。

const userModule = {
  state: {
    username: '',
    token: ''
  },
  mutations: {
    updateUser: (state, payload) => {
      // ...
    }
  }
}
@lin-xin
Copy link
Owner

lin-xin commented Apr 13, 2018

这并不是什么bug,是vuex里就这样做的吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants