M
M
marsdenden2018-12-13 08:06:14
Vue.js
marsdenden, 2018-12-13 08:06:14

Vue-router how to make this.$router.push() to new tab?

Hello!
Is it possible to programmatically go to the desired route so that it opens in a new tab, similarly <a _target="blank" .... />

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kovalchuk, 2018-12-13
@marsdenden

Well, something like this

let routeData = this.$router.resolve({name: 'routeName', query: {data: "someData"}});
window.open(routeData.href, '_blank');

Although in version 3 it already works like this
<router-link :to="{ name: 'routeName'}" target="_blank">
Текст
</router-link>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question