vue数据仓库
npm install dystore --save
- 安装
import dystore from 'dystore'
let store = {
test:"123"
}
Vue.use(dystore,store)
- 数据仓库
let a = this.$store.state.data1
this.$store.state.test = '456'
- mapState
import { mapState } from 'dystore'
{
...,
computed:{
...mapState({
test:'state.data1'
})
},
...
}
赋值(可以直接赋值)
this.test='123'
取值
<div>{{ test }}</div>
- event-bus
this.$store.$emit('testevent','123')
this.$store.$on('testevent',(res)=>{
console.log(res)
})
- chrome调试工具(应用商店搜索dystore)