I have this kind of objects in an array:
{
name: 'name1',
url: 'http://url-1.tld'
},
{
name: 'name2',
url: 'http://url-2.tld'
}
On div click, I want to to a window.location.href to the url, but I can't seem to get the url from the data to my method.
<div v-for="person in persons" v-on:click="select($event)"></div>
select: function(event) {
window.location.href( ??? )
}
Anybody have suggestions?
You need to pass the person as the argument to select, not $event:
<div v-for="person in persons" v-on:click="select(person)"></div>
select: function(person) {
window.location.href = person.url;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With