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.
If you need logic to occur before you go to a route you can import the Router Module and use it as such. I'm unsure of the best practice but I would say that it is fine to use routerLink and (click) in the same button as long as you do not interfere with the navigation. Manually navigation via this. router.
The appearance of the Button can be changed like a link by e-link class using cssClass property and link navigation can be handled in Button click. In the following example, link is added in Button click by using window. open() method.
Suppose we have a /contact route in our vue app, when a user visits the /contact page we need to redirect them to an external url https://www.google.com/contact/ instead of the same domain redirect. To redirect to an external url in Vue, we can use the window. location. href property.
You can use tag
prop.
<router-link to="/foo" tag="button">foo</router-link>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With