I'm trying to populate rows in an HTML table using the Vue framework - the data is as seen below:
TeamRows: [
{ team: 'One', times: ['1', '2', '3'] },
{ team: 'Two', times: ['4', '5', '6'] },
{ team: 'Three', times: ['7', '8', '9'] }
]
I've tried following this codepen, but with bad result - this is my HTML:
<tbody>
<tr v-for="(row, rindex) in teamRows">
<td>{{rindex}}</td>
<template>
<cell v-for="(value, vindex) in row" :value="value" :vindex="vindex" :rindex="rindex"></cell>
</template>
</tr>
</tbody>
</table>
<template id="template-cell">
<td>{{ value }}</td>
</template>
And this is the Vue component:
Vue.component('cell', {
template: '#template-cell',
name: 'row-value',
props: ['value', 'vindex', 'rindex']
});
I would like the team to go in the first column in a row and the times to follow along in as many columns as there are times. Hope someone with more Vue knowledge is able to help me out here. Cheers.
cellcomponent here it works fine: jsfiddle.net/wostex/63t082p2/81 Looks like the issue arises only when you're trying to loop components - it throws an errorrow is not defined during render. I've never encountered this to be honest, maybe someone from Vue team can clarify this (@Linus Borg ?). Also you have strange<template>wrapper for whatever reason, I don't think it's needed.celland<template>due to that codepen. Yours is simpler and it actually works. Thanks a bunch! If you post it as an answer, I can mark it as solved if you'd like.templatetag or whatever. In my own code I'm using nestedv-forwith components no problem for some reason (though I don't see a difference). What is actually broken in this code?cellis moved. Browsers are very picky about what they will allow inside certain HTML like tables. It is one of the reasons theisdirective exists.