17

I go through the documentation of Nuxt, but couldn't find information about how to open a page in a new tab. Is there a way to open a link in a new tab instead of opening it in the current tab? I tried the following code:

<nuxt-link to="/user" target="_blank">User</nuxt-link>

But it doesn't work.

JackJack
  • 612
  • 2
  • 12
  • 28

3 Answers3

41

The whole point of vue-router is navigating inside a single page application so it doesn't have a way to navigate to a blank new tab as far as I know. Fortunately there is an old fashioned thing called 'html' which has something called an anchor tag that you can use like this:

<a href="/user" target="_blank">User</a>
Andrew1325
  • 3,519
  • 1
  • 14
  • 25
17

As @anthonygore pointed out in a comment to first post. It's now working to open link in a new tab by , having all the features of router name/path link

do it with by adding target="_blank" to/inside NuxtLink to have

<NuxtLink :to="..." target="_blank">Nuxt link to external page</NuxtLink>

or just use default

<a href="..." target="_blank">A link to external page</a>
devzom
  • 676
  • 1
  • 9
  • 19
0
<a href="./user" target="_blank">User</a>

Note that the path should start with dot. If the website is not at root.

Epic Chen
  • 1,282
  • 12
  • 17