0

Is it possible to open a Vue component in new tab by vue router without page reload.

Normal Way :

<a href="http://example.com" target="_blank">HtmlExample </a>

Vue Router

<router-link to="/example" target="_blank">Vue Router Example </a>

It's works properly but i need it without page reload.

Sumon Sarker
  • 129
  • 2
  • 10
  • 1
    Does this answer your question? [Can vue-router open a link in a new tab?](https://stackoverflow.com/questions/40015037/can-vue-router-open-a-link-in-a-new-tab) – JaredMcAteer May 04 '20 at 16:20
  • "without page reload" What do you mean here? Like the current page or the page you are opening in a new tab. A new tab is a completely separate browser process so the answer would be no. – JaredMcAteer May 04 '20 at 16:22
  • Everything is work properly no problem but I want to any if there any process available to switch one component to another component by Vue router in another tab. @JaredMcAteer – Sumon Sarker May 04 '20 at 16:24
  • I don't think you're going to be able to do this with a simple router link. If you want to control another window you'll probably need to use the [postMessage](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) API and implement some system for communicating between the windows. You might be able to spawn a popup window with a specific id and set the target to the window id instead of "blank" but I don't think if pushState will work that way. – JaredMcAteer May 04 '20 at 16:49

1 Answers1

0

If I understood your issue correctly: new pages are always going to be loaded, since it's a vue lifecycle. Vue lifecycles. But what you can do here is to use browser's local storage. And when the component is mounted for example, you can share the data from your previous page.

tony19
  • 125,647
  • 18
  • 229
  • 307
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30577012) – pitamer Dec 14 '21 at 15:04