I am a starter at vue and vuetify, explanation and examples would be very nice. I am trying to get a button that sends you to an external site. Example youtube . I now have this, but it is not working.
<v-btn
color="primary"
text
@click="redirect(x.link)"
>
Share
</v-btn>
This is my redirect
methods: {
redirect(link) {
window.location.href = link;
}
}
I saw some other questions using vue-router. I'm not sure how to use that.
I hope its clear what I am asking. Thanks in advance.
I am a starter at vue and vuetify, explanation and examples would be very nice. I am trying to get a button that sends you to an external site. Example youtube. . I now have this, but it is not working.
<v-btn
color="primary"
text
@click="redirect(x.link)"
>
Share
</v-btn>
This is my redirect
methods: {
redirect(link) {
window.location.href = link;
}
}
I saw some other questions using vue-router. I'm not sure how to use that.
I hope its clear what I am asking. Thanks in advance.
Share Improve this question asked Jan 17, 2020 at 16:03 SilkeNLSilkeNL 5621 gold badge8 silver badges30 bronze badges 4- 2 Please check this , maybe can help. Regards! – Ignacio Commented Jan 17, 2020 at 16:08
-
2
it is not working
- Is it a holiday? What do you mean its not working? Did you debug? Does the redirect function get called? Is the link variable actually not null? Did you put a breakpoint or console.log and checked where the problem is? The code shown in the question does not have any problem per se and should work. Edit your question to Include answers to the questions I asked. – Mat J Commented Jan 17, 2020 at 16:09 - I have no clue what I did, but it works. I didn't change anything. I am dumbfounded. Thanks to the both of you! – SilkeNL Commented Jan 17, 2020 at 16:14
-
3
@SilkeNL Try using the
href
orto
prop on thev-btn
and remove the click handler. – Yom T. Commented Jan 17, 2020 at 16:36
1 Answer
Reset to default 8VBtn has a href
prop for this usage.
<v-btn :href="x.link">Share</v-btn>
vue-router
's purpose is to make the routing within your application (in the case of a single page application).
To link to an external web site, you need an href
attribute.