@vueblocks/vue-use-vuex
Use Vuex With Composition API Easily.
Install
yarn add @vueblocks/vue-use-vuex
Usage
useVuex
utilities just similar with Vuex Component Binding Helpers
It export these utilities:
- useState
- useGetters
- useMutations
- useActions
useState
import { useVuex } from '@vueblocks/vue-use-vuex'
export default {
...
setup () {
const { useState } = useVuex()
const localState = useState('global', {
theme: 'theme',
lang: 'lang'
})
const localState = useState('global', {
theme: state => state.theme,
lang: state => state.lang
})
const localState = useState('global', {
customTheme (state) {
return 'custom' + state.theme
}
})
const localState = useState('global', [
'theme',
'lang'
])
}
...
}
License
MIT @xiaoluoboding