I found nothing around the web. What I was wondering is if it is possible to use the v-for directive inside the template of a custom component. Here is what I have done:
HTML
<div id="macroservizi" class="col-lg-12 col-xs-12 collapse" v-if="modello">
<lista-servizi :servizi="modello"></lista-servizi>
</div>
CUSTOM COMPONENT
Vue.component('lista-servizi', {
template:
'<div id="tuttiGialla" class="collapse">'+
'<template class="servizioInlista">'+
'<div class="row" v-for="(single,index) in servizi.lineaGialla.servizi" :key="single.nomeServizio">'+
'<div class="col-lg-8 col-xs-8 nopadding">'+
'<h4 class="blu">{{single.nomeServizio}} {{index}}</h4>'+
'</div>'+
'<div class="col-lg-4 col-xs-4>"'+
'<span class="pull-right nomargin" v-on:click="mostraServiziGiallo(index)" v-bind:class="[GiallaTutti ? \'minus\' : !GiallaTutti,\'plus\']" data-toggle="collapse" data-target="\'#singoloGialla-\'+index"></span>'+
'</div>'+
'</div>'+
'<div v-bind:id="\'#singoloGialla-\'+index" class="row">'+
'<p>{{single.descrizione}}</p>'+
'</div>'+
'</template>'+
'</div>',
props: ['servizi'],
computed: {
listaServizi() {
return this.servizi
}
}
I have the following errors in the console:
- tag <template> has no matching end tag. found in ---> <ListaServizi>
vue.js:435 [Vue warn]: Property or method "index" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
found in
---> <ListaServizi>
<Root>
[Vue warn]: Property or method "single" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
I tried multiple ways to render it, but at this point I wonder if it is even possible.