Currently, I am dealing with a situation in Vue where I have an array that I need to loop over and render anchor elements for each iteration. The array is passed in as one of my props. Despite trying various methods, I find that the solutions I come up with feel like hacks. I want to make sure there isn't a simpler approach that I am overlooking.
<template v-for="(lead, index) in leads">
<a target="_blank" :href="lead.present_url"><b>foobar</b></a>
<div>{{lead.name}}</div>
<div>{{lead.id}}</div>
</template>
I have experimented with different combinations such as: :href="lead.present_url"
, href='lead.present_url'
, :href='${lead.present_url}'
(with backticks), along with other variations including using v-bind and accessing the present_url directly from the leads array like
v-bind:href='leads[index].present_url'
props: {
leads: Array
},
My query remains: What would be the optimal method to achieve this task?