Here is a list of links:
<ul id="menu">
<li v-for="item in items">
<a href v-bind:href=link>{{item.message}}</a>
</li>
</ul>
var example1 = new Vue({
el: '#menu',
data: {
items: [
{ message: 'Link1' },
{ message: 'Link2' }
]
},
computed: {
link: function() {
return f($index) // Is it possible to access the current array index here?
}
}
})
To achieve the desired result, I need to use mustache markup in the href
attribute. However, how can I access the $index
variable from within a computed function?