Vuex state数据的双向绑定

// 在从组件的computed中
computed: {
    user: {
        get() {
          return this.$store.state.user
        },
        set(v) {
          // 使用vuex中的mutations中定义好的方法来改变
          this.$store.commit('USER', v)
        }
    }
}
// 在组件中就可以使用

<input v-modle="user" />

  

posted @ 2019-04-03 15:41  *朝晖  阅读(4711)  评论(0编辑  收藏  举报