How to use a vue array inside a quote?

Asked by At

I was trying to access a vue array inside a quote like this

<div v-for="category in categories">
        <a href="{{category.link}}">Links</a>
</div>

its doesnt seem to work. Then i tried taking the code out of the quote<a href="">{{category.link}}</a> this works fine . Is there any other way to do this?

Thanks

2 Answers

1
Community On Best Solutions

You must bind your attributes when they are from Vue variables.

<div v-for="category in categories">
    <a :href="category.link">Link</a>
</div>
0
Begueradj On

You can not pass an array of links as a value of the href attribute. You can pass one link at the same time, instead.

On the other hand, if we suppose category.link refers to one link only, then you can write this:

<a href="category.link">Link</a>