[Vuejs]-Count total of v-if output in v-for

1👍

You can’t put v-for and v-if on the same element can you please provide more about your array structure so i can give you the best way but from what i have you can create do this function after getting item and subitem

items.foreach((element)=>{
element.subitemCount=0;
subitem.foreach(item=>{
if(element.id==item.item_id){
element.subitemCount++;}}

And for your vuejs you can write this

<div v-for="(item, i) in items" :key="i">  {{item.subitemCount}} </div>

Leave a comment