Answer the question
In order to leave comments, you need to log in
Vue js handling specific event?
the code itself
<li class="sidebar__item" v-for="category in sidebarList.cat">
<h2 class="sidebar__title" @click="sidebarshow()">{{category}}</h2>
<ul class="submenu" v-if='sidebarshow()'>
<li class="submenu__item" v-for="article in articles(category)">
<a href="" class="submenu__link">{{article}}</a>
</li>
</ul>
</li>
</ul>
Answer the question
In order to leave comments, you need to log in
Add the active property to data, which you use to display the desired submenu instead of sidebarshow:
<li class="sidebar__item" v-for="(category, index) in sidebarList.cat">
<h2 class="sidebar__title" @click="active = active === index ? null : index">{{ category }}</h2>
<ul class="submenu" v-if="active === index">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question