Skip to content

Commit 7eddb32

Browse files
committed
vuex-class
1 parent 3dd8dda commit 7eddb32

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

cli-socks/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"vue-class-component": "^6.0.0",
1414
"vue-property-decorator": "^8.0.0",
1515
"vue-router": "^3.0.1",
16-
"vuex": "^3.0.1"
16+
"vuex": "^3.0.1",
17+
"vuex-class": "^0.3.2"
1718
},
1819
"devDependencies": {
1920
"@types/jest": "^23.1.4",

cli-socks/src/store.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export default new Vuex.Store({
1313
actions: {},
1414

1515
// ~ component.computed
16-
getters: {},
16+
getters: {
17+
countAlias(state) {
18+
return state.count;
19+
}
20+
},
1721

1822
// ~ redux.actions
1923
mutations: {

cli-socks/src/views/Counter.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="counter">
33
<h1>Vuex Counter</h1>
4-
<p>{{ count }}</p>
4+
<p>{{ countAlias }}</p>
55
<p>
66
<button @click="increment">+</button>
77
<button @click="decrement">-</button>
@@ -11,21 +11,23 @@
1111

1212
<script lang="ts">
1313
import { Component, Vue } from "vue-property-decorator";
14-
import { mapState, mapGetters } from 'vuex';
14+
//import { mapState, mapGetters } from 'vuex';
15+
import { State, Getter, Action, Mutation, namespace } from 'vuex-class';
1516
1617
@Component
1718
export default class Counter extends Vue {
1819
get count(): number {
1920
return this.$store.state.count;
2021
}
2122
23+
@Getter countAlias!: number;
24+
25+
2226
increment(): void {
2327
this.$store.commit('increment');
2428
}
2529
26-
decrement(): void {
27-
this.$store.commit('decrement');
28-
}
30+
@Mutation decrement!: Function;
2931
}
3032
</script>
3133

cli-socks/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"importHelpers": true,
88
"moduleResolution": "node",
99
"experimentalDecorators": true,
10+
"allowJs": true,
1011
"esModuleInterop": true,
1112
"allowSyntheticDefaultImports": true,
1213
"sourceMap": true,

0 commit comments

Comments
 (0)