Passing forEach loop data to href attribute in Vue
Solution 1:
You actually want to use v-for
on the element that you want multiple of, and you need to bind a :key
as well:
<template>
<div class="lead-container">
<div v-for="lead in leads" :key="lead.id">
<a target="_blank" :href="lead.present_url">
<strong>foobar</strong>
</a>
<div>{{lead.name}}</div>
<div>{{lead.id}}</div>
</div>
</div>
</template>
<script>
export default {
props: {
leads: {
type: Array,
default: () => [],
}
}
}
</script>