How to open a link in a new tab in a vue application when using vue-router ?
- association: stackoverflow.com/q/40015037/5610621 - Bald
|
1 answer
In vue-route starting from version 3.0.1 for route-link you need to use the target parameter with the value _blank , example:
<router-link :to="{ name: 'routeName'}" target="_blank">Link Text</router-link> if this method is not suitable, then it can be done in the event handler we need:
let route = this.$router.resolve({name: 'routeName', params: {}}}); window.open(route.href, '_blank'); |