Answer the question
In order to leave comments, you need to log in
What is the best way to structure array elements?
Hello, I want to split large components into smaller ones with smaller dependencies, is there any performance advantage of such a data structure (I currently use it):
items: [
{ type: 'someTypeRequest', ... },
{ type: 'image', ... },
{ type: 'someAnotherTypeRequest2', ... },
{ type: 'video', ... },
]
items: {
requests: [
{ type: 'someTypeRequest1', ... },
{ type: 'someAnotherTypeRequest2', ... },
],
media: [
{ type: 'image', ... },
{ type: 'video', ... }
]
}
<template v-for="item in items">
<component-a v-if="item.type === 'image'" ...здесь много пропсов></component-a>
<component-b v-if="item.type === 'video'" ...здесь много пропсов></component-b>
<component-c v-if="item.type === 'someTypeRequest'" ...здесь много пропсов></component-c>
<component-d v-if="item.type === 'someAnotherTypeRequest2'" ...здесь много пропсов></component-d>
...и ещё компоненты здесь
</template>
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