How to pass a value from Vue data to href?

前端 未结 3 536
-上瘾入骨i
-上瘾入骨i 2020-11-28 04:05

I\'m trying to do something like this:

           


        
相关标签:
3条回答
  • 2020-11-28 04:12

    You need to use v-bind: or its alias :. For example,

    <a v-bind:href="'/job/'+ r.id">
    

    or

    <a :href="'/job/' + r.id">
    
    0 讨论(0)
  • 2020-11-28 04:24

    Or you can do that with ES6 template literal:

    <a :href="`/job/${r.id}`"
    
    0 讨论(0)
  • 2020-11-28 04:30

    If you want to display links coming from your state or store in Vue 2.0, you can do like this:

    <a v-bind:href="''"> {{ url_link }} </a>

    0 讨论(0)
提交回复
热议问题