Answer the question
In order to leave comments, you need to log in
How can I hide an element when it is clicked?
Hello, there is a list of elements, the point is that when you click on it, buttons appear, I did it, now everyone has it, but the problem is that when I click on an element, buttons appear, when I click again, it does not disappear
<template>
<div class="row scroll-comments">
<div class="list list-row block">
<div
class="list-item"
v-for="(comment, indexComment) in commentsList"
:key="comment.id"
:class="{'list-item-checked': buttonIndexVisible === indexComment}"
@click="showHiddenActionBtn(indexComment)"
>
<transition name="fade">
<actionBtn
v-if="buttonIndexVisible === indexComment"
:idComment="comment.id"
/>
</transition>
<div>
<span class="w-48 avatar gd-success">
<img :src="profile.userImg" :alt="profile.firstName[0] + '.' +profile.lastName[0]" />
</span>
</div>
<div class="flex item-author text-color">
{{profile.firstName + ' ' + profile.lastName}}
<div class="item-except text-muted text-sm h-1x">{{comment.text}}</div>
</div>
</div>
</div>
</div>
</template>
import actionBtn from '@/components/actionBtn.vue';
import { db } from '../main';
export default {
name: 'commentList',
components: { actionBtn },
data() {
return {
commentsList: [],
buttonIndexVisible: '',
profile: {
firstName: 'Pavel',
lastName: 'Ivanov',
userImg: 'https://img.icons8.com/color/48/000000/guest-male.png',
},
};
},
methods: {
showHiddenActionBtn(indexComment) {
this.buttonIndexVisible = indexComment;
},
},
firestore() {
return {
commentsList: db.collection('comments').orderBy('createdAt'),
};
},
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question