How to handle Paste(Ctrl+v or with mouse) event in vue.js?

You can simply use the paste event:

<textarea @paste="onPaste"></textarea>

...
  methods: {
    onPaste (evt) {
      console.log('on paste', evt)
    }
  }
...

It's not a vue-specific event. See https://developer.mozilla.org/en-US/docs/Web/Events/paste


Additionally you can disable Past event (CTRL+V) for an input, with the .prevent function.

<input v-model="input" @paste.prevent class="input" type="text">

Past action will be automatically disabled for this input


Using the onPaste method in Vue 2.6, the evt.target.value is empty. To get the text value, use:

  methods: {
    onPaste (evt) {
      console.log('on paste', evt.clipboardData.getData('text'))
    }
  }

Tags:

Vue.Js

Vuejs2