VUE - Generate dynamic components

0

I have a json list which contains a special field: tipo this is responsible for knowing which component should be displayed, there are several types clarifying.

{
 id: 1,
 nombre: Listado de tareas,
 tipo: BlockComponent
},
 id: 1,
 nombre: Listado de tareas,
 tipo: LineComponent
},

I'm getting this information by axios . My problem is, how can I know which component to render, because they can be several of the same type or even none. With Laravel I was doing it very easy because it is php and it was similar to this:

@foreach($bloques as $bloque)
     @include('components.'. $bloque['tipo'], [
     'info' => $info])
 @endforeach

But with how you could do it in such a way that you know which component to show.

I was thinking of something similar to this:

<div class="row" v-for="(item, index) in bloques" :key="index">
    <{{item.tipo}}></{{item.tipo}}>
</div>

But of course, it does not render them.

    
asked by DoubleM 13.12.2018 в 19:12
source

0 answers