How to store the module of "vuex-module-decorators" in Vue class component with minimal performance impact?

378 Views Asked by At

The simplest way to store the vuex module in Vue component is:

import { Vue, Component } from "vue-property-decorator";
import { getModule } from "vuex-module-decorators";
import ExampleModule from "@Store/ExampleModule";


@Component
class ExampleComponent extends Vue {

  private exampleModule: ExampleModule = getModule(ExampleModule);

  private reuse(): void {
    this.exampleModule.stateField1;
  }

  private reuseAgain(): void {
    this.exampleModule.stateField2;
  }
}

Now, the whole exampleModule is reactive data of the Vue component. Is it all right?

0

There are 0 best solutions below