Enclosing a router-link tag in a button in vuejs

前端 未结 10 691
爱一瞬间的悲伤
爱一瞬间的悲伤 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条回答
  •  情话喂你
    2020-12-23 16:23

    As of Vue-Router 3.1.0, the ideal way is to use the slots api.
    Documentation Here

    @choasia's answer doesn't allow for props to be passed to the component
    @Badacadabra's answer causes problems with library-buttons (such as button margins)

    Here's how the solution would work with the slots API

    
        
    
    

提交回复
热议问题