When it comes to accessing the parent ul
, I am familiar with using this.$refs.listOfItems
. However, I am unsure of how to retrieve all the li
elements within the ul
list.
While the typical JS approach involves using
document.getElementById("listOfItems").getElementsByTagName("li");
, I am curious about Vue.js helpers such as this.$refs
.
<template>
<ul id="listOfItems" ref="listOfItems">
<li v-for="item in items">{{ item.name }}</li>
</ul>
</template>
<script>
export default {
mounted: {
let ul = this.$refs.listOfItems
let lis = // HOW TO GET ALL LIs using `this.$refs.listOfItems`
}
}
</script>