这是我在vuex商店中的吸气剂:
const getters= {
getUser: (state:any) => {return state.user}
};
我认为:
<script lang="ts">
...
import {createNamespacedHelpers} from 'vuex'
const {mapMutations,mapGetters} = createNamespacedHelpers('user');
export default Vue.extend({
computed: {
...mapGetters([
'getUser'
])
},methods: {
...mapMutations([
'change'
]),login() {
this.change(email); //This is a function in the mutations. And this is working
this.loggedin = this.getUser(); // Here it says error
}
}
});
我得到了错误:
TypeError: this.getUser is not a function
。不过,对变异函数的调用this.change(email);
正在工作。