38

right now, I need to add event.preventDefault() to all of my click events in my Vue.js buttons:

<button class="btn btn-primary" v-on:click="someAction($event)">Action</button></p>

methods: {
 someAction (e) {
   e.preventDefault()
   console.log('in some action')
 },
}

Does anyone know of a way have event.preventDefeault() be the default setting? Right now it's very annoying to have to include the event.preventDefault() in every click event.

Thanks in advance!

John Grayson
  • 1,378
  • 3
  • 17
  • 30

1 Answers1

71

You can use prevent modifier:

@click.prevent="YourMethod"

You can look event modifier for more information.

tony19
  • 125,647
  • 18
  • 229
  • 307
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231