Trying to access the value of the key with Vue.js which is new for me. I want to use the key as the id and access the title with key.title or something similar if possible. Here is the code I am trying:
HTML
<ul id="all">
<li v-for="(song,key) in songs" :class="{ active: song.isActive }" v-bind:id="key">
{{ key.title }} //Hound Dog
</li>
</ul>
Javascript
var vm = new Vue({
el: '#all',
data: {
songs: [
a:{
title:'Hound Dog',
lyrics:'You aint nothing but a hound dog, crying all the time',
isActive: true
},
b:{
title:'Long Gone',
lyrics:'I am long gone today',
isActive: false
}
]
}
})
songsis not a valid javascript object. Does it really havea:andb:in it? Either you want an object with a and b as properties or an array of song objects.