Click event in router-link - Stack Overflow
巴扎黑
巴扎黑 2017-06-12 09:30:57
0
2
582
<li :class="{active: show === 'daily'}">
  <router-link @click="displayArticle('hot')" to="/home/article">日报</router-link> 
</li>

Why does it have no effect if I write it like the above, but I can change it to the following one? router-link Can't events be bound to tags?

<li :class="{active: show === 'hot'}" @click="displayArticle('hot')">
  <router-link  to="/home/article">热门</router-link>  
</li>
巴扎黑
巴扎黑

reply all(2)
洪涛

router-link will prevent click events

You can only use @click.native="displayArticle('hot')" in router-link

Generally do not add it to router-link

滿天的星座

To bind native events to custom components, you need to add the .nativemodifier document portal

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template