One of the challenges I'm facing involves displaying a div when a child component is clicked. This component is rendered multiple times on the page without any kind of loop. The tricky part is that when I show the div in one specific instance of the component, I want to hide it in all the other instances. I attempted to use a reference to close all instances through DOM manipulation, but unfortunately, that approach did not yield the desired outcome.
<template>
<span>
<div class="options--small" @click="toggleOptions" />
<div v-show="showOptions" ref="test" class="options-menu">
<slot />
</div>
</span>
</template>
<script>
export default {
name: 'ShowOptions',
data () {
return {
showOptions: false
}
},
methods: {
toggleOptions () {
this.$refs.test.style.display = 'none'
this.showOptions = !this.showOptions
}
}
}
</script>