In a Vue app I have a paste listener
on a textarea
with the intention to run validation code when the user pastes data into this field. When I log the paste event I can see in the console that the data that was pasted into the field is there under event -> target -> value
. I can't seem to access this with event.target.value
though. What am I doing wrong?
Minimal example:
<div id="app">
<textarea name="myField" @paste="onPaste"></textarea>
<p>Field name: {{ fieldName }}</p>
<p>Pasted data: {{ pasted }}</p>
</div>
var app = new Vue({
el: '#app',
data: {
fieldName: '',
pasted: ''
},
methods: {
onPaste(event){
console.log(event)
this.message = event.target.name
this.paste = event.target.value
}
}
})