Skip to content
Advertisement

Row is getting duplicated in Vue

My column is duplicating and I don’t understand why. It doesn’t happen to the columns that don’t have the class applied to them.

What can I do?

JavaScript

This is the array

JavaScript

And this is the .children-row class style

JavaScript

What i’m looking for is to have the objects which have the same Id, be grouped into the same table cell.

This is what i currently have, the problem is that the second row, shows up twice

Photo

Advertisement

Answer

Problem is here:

JavaScript

The div component with its content will be generated as many times as many there are items with the same Id (because of v-for directive). For those columns, you will also apply the children-row class because this is the case where (…).lenght will be bigger than one. (That’s why you can see that all duplicated columns have children-row applied)

If you change the first v-for directive to iterate only on the rows with unique Id you should get rid of duplicate rows

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement