[Vuejs]-Vue.js app opening url links from a drop down in a new page

1๐Ÿ‘

โœ…

Your code needs to change a bit:

href: "https://www.cancer.gov/publications/dictionaries/cancer-terms target='_blank'"

notice the target='_blank', target is an attribute of the a element and not part of the URL

so the data need to change to something like this:

linksExternal: [
  { name: "NCI Dictionary",  href: "https://www.cancer.gov/publications/dictionaries/cancer-terms", target="_blank", icon: "dns" }
]

and the template to this:

...
<li v-for="li in linksExternal" :key="li.name">
  <a :href="li.href" :target="li.target">
    <i class="material-icons">{{ li.icon }}</i>
  </a>
</li>
...

or simply if all the links will need to open in a new tab:

...
<li v-for="li in linksExternal" :key="li.name">
  <a :href="li.href" target="_blank">
    <i class="material-icons">{{ li.icon }}</i>
  </a>
</li>
...
๐Ÿ‘คTedMeftah

1๐Ÿ‘

try using target="_blank" inside:

<a :href="li.href" target="_blank">
<i class="material-icons">{{ li.icon }}</i>
</a>

1๐Ÿ‘

Iโ€™m not too sure about the rest of the markup, but I suggest you remove the target part from your linksExternal object, and put it in the <a> element as below


<a :href="li.href" target="_blank">Cool link that opens in another page</a>

Leave a comment