-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
38 lines (32 loc) · 872 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Vue from "vue";
export default {
install(_vue) {
_vue.mixin({beforeCreate: function() {
const options = this.$options;
if(options.store) {
this.$store = options.store;
} else if (options.parent && options.parent.$store) {
this.$store = options.parent.$store
}
}});
},
hug(store) {
new Vue({
data() {
return store.state;
}
})
this.makeDispatchable(store);
this.makeCommitable(store);
},
makeDispatchable(store) {
store.dispatch = function(action, val) {
store.actions[action](store, val);
}
},
makeCommitable(store) {
store.commit = function(commit, val) {
store.mutations[commit](store, val);
}
},
}