-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvuex-state.html
48 lines (46 loc) · 904 Bytes
/
vuex-state.html
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
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Components Example</title>
<script src="./vue.js"></script>
<script src="./vuex.js"></script>
</head>
<body>
<div id="app"></div>
<script>
Vue.use(Vuex);
const store = new Vuex.Store({
state: {
count: 0,
},
mutations: {
increment(state) {
state.count++;
},
},
});
const Counter = {
template: `<div>{{ count }}</div>`,
computed: {
count() {
return this.$store.state.count + "哈哈";
},
},
};
new Vue({
el: "#app",
data: {},
computed: {},
components: {
Counter,
},
store,
template: `
<div class="app">
<counter></counter>
</div>
`,
});
</script>
</body>
</html>