12

Using vuejs 2.5 if there is a way in router-link to set

target= '_blank'

? I tried this way:

<router-link :to="{name: 'UserProfileView', params: {id: participantUser.user_id}, target: '_blank' }"  >  

but failed...

Thanks!

user2339232
  • 757
  • 3
  • 11
  • 22
  • 1
    Possible duplicate of [Can vue-router open a link in new tab?](https://stackoverflow.com/questions/40015037/can-vue-router-open-a-link-in-new-tab) – samayo Jan 15 '18 at 15:41

4 Answers4

32

You will add target='_blank' like on <a> tag

Hope is clear

kalidou.diagne
  • 432
  • 3
  • 8
1

You must to use method. Method looks something like this:

methods: {
     redirectToUserView(user) {
      const route = this.$router.resolve({
        name: 'UserProfileView',
        params: {id: participantUser.user_id},   
      });
      window.open(route.href, '_blank');
    },
 }
Dm Prkp
  • 108
  • 8
0

Below code is to open a new tab with parameter.

With router link=

<router-link
                  :to="{ name: 'task_section',query: {reportId: item.task,}}"
                  target="_blank"> Link Text
              </router-link>

Now access to the sented data

this.$route.query.reportId
Mahadi Hassan
  • 149
  • 1
  • 8
0

Perfectly worked for my code "target='_blank'" with external redirect.

<b-dropdown-item
                :key="props.row.banner_id"
                :to="{name:'banners-preview',
                      params: { id: props.row.banner_id } }"
                target='_blank'
              >
                <feather-icon
                  icon="ExternalLinkIcon"
                  class="mr-50"
                />
                <span>Preview Link</span>
</b-dropdown-item>
lincolndu
  • 93
  • 1
  • 8