0👍
I think you want to be using @change
instead so you can catch the instance of the value being updated then send the emit.
0👍
When you want an updated variable to be emitted, watch
the variable. Only look at the DOM when there’s no viewmodel state to tell you what you need to know.
By using a change
event to emit a data item, you’re mingling concepts and depending on order of execution. The change event does not guarantee that the data item is updated by the time the handler fires. If you are going to emit from an event, you should emit event.target.value
, not the data item which is updated separately.
If you want to emit the data item, you should be watching it for changes.
Since you’re emitting changes, your component likely shouldn’t own the data item, it should receive it as a prop.