Home > Software design >  Access iterable in sibling tag
Access iterable in sibling tag

Time:09-14

As stated i want to access an iterable from a sibling tag. Unfortunatly its in a table so i cant just do it by wrapping the stuff with a diff and push the iteration one lvl outside. Also the items are tablerows so i cant make the sibling to a child. I guess this is easier with an example(thats what i want to do):

<table>
  <tr v-for="element in elements">
    ...
   </tr>
   <tr v-for="hit in element.hits">
     ...
   </tr>
</table>

Obviously this doesnt work since once i close the first tr i drop out of scope. Is there any work around that? Regardiest regards, Sean

CodePudding user response:

v-for can be used on <template> that wraps <tr>, in this case it isn't rendered itself:

<template v-for="element in elements">
  <tr>
    ...
   </tr>
   <tr v-for="hit in element.hits">
     ...
   </tr>
</template>
  • Related