You are looking for .prevent modifer.
<a href="/threads/my-first-thread/" @click.prevent="openThread">My first thread</a>
See Event Handling in the guide:
Event Modifiers
It is a very common need to call
event.preventDefault()
orevent.stopPropagation()
inside event handlers. Although we can do this easily inside methods, it would be better if the methods can be purely about data logic rather than having to deal with DOM event details.To address this problem, Vue provides event modifiers for
v-on
. Recall that modifiers are directive postfixes denoted by a dot.
.stop
.prevent
.capture
.self
.once
.passive
So:
<a href="/threads/my-first-thread/" @click.prevent="openThread">My first thread</a>
<!-- -------------------------------------^^^^^^^^ --->
...or of course, accept the event parameter and call preventDefault.
Live Example on jsFiddle (since Stack Snippets don't allow off-site links).