https://github.com/wangdahoo/map-state-vmodel
mapState for v-model
https://github.com/wangdahoo/map-state-vmodel
Last synced: 10 months ago
JSON representation
mapState for v-model
- Host: GitHub
- URL: https://github.com/wangdahoo/map-state-vmodel
- Owner: wangdahoo
- Created: 2018-01-18T17:26:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-01T07:34:44.000Z (about 7 years ago)
- Last Synced: 2025-06-01T11:20:11.127Z (about 1 year ago)
- Language: JavaScript
- Size: 88.9 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# map-state-vmodel
> mapState for v-model
### Install
```bash
$ npm i map-state-vmodel
```
### How to Use
* in *.vue
```vue
import {mapStateVModel} from 'map-state-vmodel'
export default {
computed: {
...mapStateVModel('user', [
'userName'
])
}
}
```
* in store file `user.js`
```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.