Typescript vuex存储基于类的类型脚本

Typescript vuex存储基于类的类型脚本,typescript,vue.js,vuex,decorator,store,Typescript,Vue.js,Vuex,Decorator,Store,嘿,伙计们,我正在使用decorators处理一个Vue,Vuex强类型模板项目 因为我对整个商店都是新手,所以我无法理解如何正确地配置我的商店,使其能够像我预期的那样在我的组件中工作 我最终想要实现的是呼吁行动。。。我的不同存储模块的配置如下: this.$store.nameOfMyModule.NameOfAction this.$store.<nameOfMyModule.NameOfGetter 这里是指向的链接,我认为最好使用mapActions和mapGetters: im

嘿,伙计们,我正在使用decorators处理一个Vue,
Vuex
强类型模板项目

因为我对整个商店都是新手,所以我无法理解如何正确地配置我的商店,使其能够像我预期的那样在我的组件中工作

我最终想要实现的是呼吁行动。。。我的不同存储模块的配置如下:

this.$store.nameOfMyModule.NameOfAction
this.$store.<nameOfMyModule.NameOfGetter

这里是指向

的链接,我认为最好使用
mapActions
mapGetters

import { mapActions, mapGetters } from 'vuex'

//...

computed: {
   ...mapGetters('tickets', [
        tickets
   ]),
   ...mapGetters('users', [
        users
   ])
},

methods : {
   ...mapActions('tickets', [
        fetchTickets
   ]),
   ...mapActions('users', [
        fetchUsers
   ])
}
//...
之后,您可以直接在组件中使用
this.fetchTickets()
this.tickets


最后,您必须将
fetchUsers
放在action的
users
模块中,而不是
fetchTickets
我认为最好使用
mapActions
mapGetters

import { mapActions, mapGetters } from 'vuex'

//...

computed: {
   ...mapGetters('tickets', [
        tickets
   ]),
   ...mapGetters('users', [
        users
   ])
},

methods : {
   ...mapActions('tickets', [
        fetchTickets
   ]),
   ...mapActions('users', [
        fetchUsers
   ])
}
//...
之后,您可以直接在组件中使用
this.fetchTickets()
this.tickets


最后,您必须将
fetchUsers
放在action的
users
模块中,而不是
fetchTickets

,因此mapAction的第一个字符串指的是我的存储模块,第二个字符串是我要获取mappted的所有函数的列表?我的store.index是否为此正确配置?我看到了多种不同的方式。另外,由于我没有方法或计算对象,我如何在类样式的ts格式中使用spread mapActions操作符。是的。您可以查看这些链接以了解如何创建自定义组件:@component({methods:mapActions('ticket',[tickets])),因此,mapAction的第一个字符串指向我的存储模块,第二个是我要获取mappted的所有函数的列表?我的store.index是否正确配置了该属性?我看到了多种不同的方式。另外,由于我没有方法或计算对象,我如何在类样式的ts格式中使用spread mapActions操作符。是的。您可以查看这些链接以了解如何创建自定义组件:@component({methods:mapActions('ticket',[tickets]))