最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Vuetify how to get a working link in a v-btn - Stack Overflow

programmeradmin2浏览0评论

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 or to prop on the v-btn and remove the click handler. – Yom T. Commented Jan 17, 2020 at 16:36
Add a ment  | 

1 Answer 1

Reset to default 8

VBtn 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.

发布评论

评论列表(0)

  1. 暂无评论