Enclosing a router-link tag in a button in vuejs

前端 未结 10 700
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 15:34

Can I wrap or enclose a router-link tag in a button tag?

When I press the button, I want it to route me to the desired page.

10条回答
  •  萌比男神i
    2020-12-23 16:35

    While the answers on here are all good, none seem to be the simplest solution. After some quick research, it seems that the real easiest way to make a button use vue-router is with the router.push call. This can be used within a .vue template like this:

    
    

    Super simple and clean. I hope someone else finds this useful!

    Source: https://router.vuejs.org/guide/essentials/navigation.html

提交回复
热议问题