@shimochi/vuex-map-state-two-way

1.1.1 • Public • Published

vuex-map-state-two-way

Installation

$ npm install @shimochi/vuex-map-state-two-way --save

Usage

<template>
  <form>
    <input v-model="name">
    <input v-model="email">
  </form>
</template>

<script>
import { mapStateTwoWay } from 'vuex-map-state-two-way';

export default {
  computed: {
    ...mapStateTwoWay('user', ['name', 'email'])
  }
}
</script>
export default {
  namespaced: true,
  state: {
    name: null,
    email: null
  },
  getters: {
    name: state => state.name,
    email: state => state.email
  },
  mutations: {
    name (state, name) {
      state.name = name
    },
    email (state, email) {
      state.email = email
    }
  },
  actions: {
    setName ({ commit }, value) {
      commit('name', value)
    },
    setEmail ({ commit }, value) {
      commit('email', value)
    }
  }
}

License

The vuex-map-state-two-way is open source software licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i @shimochi/vuex-map-state-two-way

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

4.89 kB

Total Files

5

Last publish

Collaborators

  • shimochi