I am using a custom input component that has the following structure:
<select @change="$emit('change', $event.target.value)">
...
</select>
By emitting a change
event with the current input value ($event.target.value
), I can capture and use the value in my Vue instance.
Here is how I implement this component:
<mycomponent @change="someMethod"></mycomponent>
The value is automatically passed to the method someMethod
. In my main Vue instance, I have defined someMethod
like this:
someMethod(value){
console.log(value);
}
If I wanted to include another value when calling someMethod
, for example 'My String Data', how would I achieve this?
<mycomponent @change="someMethod('My String Data')"></mycomponent>
Is it possible to receive both the input value and 'My String Data' in the someMethod
function?