TypeScript
- 1 ответ
- 0 вопросов
1
Вклад в тег
<!-- App.vue -->
<template>
<div id="q-app">
<router-view />
</div>
</template>
<script lang="ts">
import { ExampleModule } from 'src/store/module-example';
export default {
name: 'App',
created() {
const myModule = new ExampleModule({ store: this.$store, name: 'example'});
myModule.setProp(false); // Mutation calling;
myModule.confirmProp(); // Action calling
}
};
</script>
// src/store/module-example/index.ts
import {
VuexModule, Module, Mutation, Action
} from 'vuex-class-modules';
@Module
export class ExampleModule extends VuexModule {
prop: boolean = false;
@Mutation
setProp(payload: boolean) {
this.prop = payload;
}
@Action
confirmProp() {
this.setProp(true);
}
}