3π
β
You can use the prevent
modifier on paste to prevent the native event and you donβt need to use the $ref
in this case.
Check @paste.prevent
:
new Vue({
el: "#app",
data: {
todo: ''
},
methods: {
onPaste: function(event) {
let clipped = event.clipboardData.getData('text');
console.log(clipped)
this.todo = '';
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<input type="text" v-model="todo" @keyup.enter="addTodo" @paste.prevent="onPaste">
</div>
π€Leonardo Nakao
Source:stackexchange.com