I'm trying to figure how to make each of my items listed, independently be hidden and show, currently when you open one the other opens as well. Would I need to use an index of some sort? I am using v-show because I need the content to be rendered before hand and hidden on load but shown on click.
<template>
<div>
<div v-for="item in items" :key="item">
{{ item.title }}
<div v-if="item.examples != null">
<a v-on:click="visibleExample = !visibleExample">Example</a>
<transition name="fade">
<div v-show="visibleExample">
<div v-for="example in item.examples" :key="example">
{{ example }}
</div>
</div>
</transition>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
visibleExample: false,
items: [{
title: 'Title',
examples: [
'Question',
'Answer'
]
},
{
title: 'ABC',
examples: [
'1',
'2',
'3',
'4',
'5'
]
}
]
}
}
}
</script>
Please note: This is a stripped version of my original code for simplicity.