vue-stores
v1.0.3
Published
Share the root states and methods in every component.
Downloads
4
Readme
vue-stores
Share the root states and methods in every component.
GitHub
https://github.com/ccforward/vue-stores
NPM
Demo
https://ccforward.github.io/vue-stores/
Usage
install
$ npm install vue-stores --save
$ yarn add vue-stores
Root Component
import stores from 'vue-stores'
Vue.use(stores)
new Vue({
...
data: {
state: {
showModal: false,
global: {
txt: 'shared Text'
}
}
},
methods: {
toast(){
alert(this.state.global.txt)
}
}
...
})
Child Component
export default {
...
methods: {
toggle(){
this.modal = !this.modal
}
},
stores: {
txt: 'state.global.txt',
modal: 'state.showModal',
alert(){
return 'toast'
}
}
...
}