I would like to know whats the correct way of using ...mapActions([])
within a Typescript vue class component.
this is how I do it:
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { mapActions } from "vuex";
@Component
export default class UsersAdd extends Vue {
userName: string = "";
...mapActions(["newUser"]) /*mapAction from vuex */
addUser() {
console.log("...adding new user");
this.newUser(this.userName);
}
}
</script>
and as you can tell it's not working...
with Javascript I do it this way.
methods:{
...mapActions(["newUser"])
}
How can I do it with Typescript class component?
Edit: I have tried it this way, but it's still not working
@Component({
methods: {
...mapActions(["newUser"]) /*mapAction from vuex */
}
})
export default class UsersAdd extends Vue {
userName: string = "";
addUser() {
console.log("...adding new user");
this.newUser(this.userName);
}
}
charts!: any[]
in the link. I suppose in your case it needs to benewUser!: (username: string) => void
. – Belgrade