Remove redundant values between actions names and template attributes events.
I often use the same values for actions names and component event methods, so this will allow simplicity.
Make the following code valid.
Currently it's impossible to reference On.UPDATE_SEARCH_TERM from @input.
A valid code will clone the constant value in the template instead of reference it.
<template>
<v-text-field @input="On.UPDATE_SEARCH_TERM"/>
</template>
<script>
import {mapActions} from 'vuex';
import * as On from "../store/actionKeys";
export default {
name: 'minimal-exemple',
methods: {
...mapActions([On.UPDATE_SEARCH_TERM])
}
}
</script>
created () {
this.On = On
}
Assuming On was available in the template, the result of your code would be:
<v-text-field @input=" 'someString' "/>
Which of course is not a valid callback function - it's a string. So making constants avaliable in templates whatever way won't solve your problem.
Thanks you both
So I use this now:
<template>
<v-text-field @input="termInputChanged" />
</template>
<script>
import {mapActions} from 'vuex';
import {On} from "../store/keys";
export default {
name: 'minimal-test',
methods: {
...mapActions({
'termInputChanged': On.UPDATE_SEARCH_TERM
})
}
}
</script>
Most helpful comment
So I use this now: