I'm trying to determine how to pass an event down with a bound change listener to a child input component. I'm using wrapped input components, but want to be able to define methods in the parent component.
//App.js:
<currency-input :input="changeInput" :value="inputs.name"></currency-input>
<input :input="changeInput" :value="inputs.address"></input>
<script>
export default: {
changeInput(e) {
this.$store.dispatch('changeInput', e);
}
}
<script>
//currency-input
<masked-input type="currency" class="currency-input" :mask="currencyMask">
</masked-input>
//store.js vuex action
changeProp: function( state, e ){
state.dispatch('change_prop', e.target.name, e.target.value);
}
This fires on the 'input', but not on the 'currency-input'. If I add @input
prop to the currency-input
and bind it to the masked-input
's @input
, then the function runs but the value of 'e' is just the input value, not the event.
Why is this happening and how can I pass the function so that the parameter ends up being the event itself?
.native
modifier on the event? Something like@change.native="changeInput"
– Ikbel