I have a v-repeat list of items that are pulled from json.
I want to target the last item in the list to change its class.
How would I do this? My code is below...
HTML
<div id="app">
...
<ul id="menu">
<li v-repeat="items">
<i class="material-icons">{{ icon }}</i>
{{ name }}
</li>
</ul>
</div>
JS
var apiUrl = 'inc/menu.json.php'
new Vue({
el: '#app',
data: {
active: true,
items: []
},
ready: function(){
this.fetchData()
},
methods: {
toggle: function () {
this.active = !this.active;
},
fetchData: function(){
var xhr = new XMLHttpRequest(),
self = this
xhr.open('GET', apiUrl)
xhr.onload = function () {
self.items = JSON.parse(xhr.responseText)
}
xhr.send()
}
}
});