Answer the question
In order to leave comments, you need to log in
What about typed components?
In general, there is a certain problem.
There is a certain feed in which there are different types of news, for example, raz, dva, tri
. And data comes from the api in this format:
[
{
type: 'raz',
data: {...}
},
{
type: 'dva',
data: {...}
},
...
]
<template>
<div>
<div v-for="item in feed">
<feed-raz v-if="item.type==='raz'" :data="item.data" />
<feed-dva v-if="item.type==='dva'" :data="item.data" />
<feed-tri v-if="item.type==='tri'" :data="item.data" />
</div>
</div>
</template>
<script>
import feedRaz from './feedRaz'
import feedDva from './feedDva'
import feedTri from './feedTri'
export default {
components: {
feedRaz, feedDva, feedTri
}
}
</script>
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