Skip to content

wangdahoo/map-state-vmodel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

map-state-vmodel

mapState for v-model

Install

$ npm i map-state-vmodel

How to Use

  • in *.vue
<template>
  <div>
    <input v-model="userName" />
  </div>
</template>
<script>
import {mapStateVModel} from 'map-state-vmodel'

export default {
  computed: {
    ...mapStateVModel('user', [
      'userName'
    ])
  }
}
</script>
  • in store file user.js
import {createSetters} from 'map-state-vmodel'

const state = {
  userName: 'wangdahoo'
}

const mutations = {
  ...createSetters(state)
}

const getters = {}

const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  getters,
  actions
}

That's it.

About

mapState for v-model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published