I have in Vue.js code
<div class="footer-items">
<span v-for="link in links" :key="link.name">
<a :href="link.Link" class="tertiary--text footer-links">{{ link.name }}</a>
</span>
</div>
The this gives me a footer with some links. I would like to have some of these links open an external window or tab.
The array that it loads from is:
data: () => ({
links: [
{ name: "Home", Link: "/dashboard" }, // needs to open same page
{ name: "PubMed", Link: "https://www.ncbi.nlm.nih.gov/pubmed" } // needs new window
]
This works but it open in the same window, I've tried:
{ name: "PubMed", Link: "https://www.ncbi.nlm.nih.gov/pubmed/,_blank" }, // error page
{ name: "PubMed", Link: "https://www.ncbi.nlm.nih.gov/pubmed/','_blank" }, // open same page
{ name: "PubMed", Link: "https://www.ncbi.nlm.nih.gov/pubmed/"','"_blank" }, // won't compile
Link: "https://www.ncbi.nlm.nih.gov/pubmed/ target=_blank" // opens same window
Is it possible programmatically send it to the href. I can't change the href because not all pages need to open in a new window.
I changed the code to:
<a :href="link.Link" target="link.place" class="tertiary--text
footer-links">{{ link.name }}</a>
and added to the array a location:
{ name: "Home", Link: "/dashboard", place: "_self" },
{name: "PubMed", Link: "https://www.ncbi.nlm.nih.gov/pubmed/",
place: "_blank"
},
And they all open in new windows. All help is appreciated.
:in:target="link.place":. Please consider addingrel="noopener noreferrer"for the links withtarget="_blank". You can learn more about this: mathiasbynens.github.io/rel-noopener