如果我明白你的問題,你可能會想是這樣的:
<div id="demo">
<table border="1">
<template v-for="respondent in respondents">
<tr>
<td colspan="2" class="respondent">Respondent #{{respondent.id}}</td>
</tr>
<tr v-for="q in respondent.questions">
<td>{{q.question}}</td>
<td>{{q.answer}}</td>
</tr>
</template>
</table>
</div>
JS
new Vue({
el: '#demo',
data: {
respondents: [
{
id: 1,
questions: [
{ question: '1st Question (#1)', answer: '1st Answer (#1)' },
{ question: '2nd Question (#1)', answer: '2nd Answer (#1)' }
]
},
{
id: 2,
questions: [
{ question: '1st Question (#2)', answer: '1st Answer (#2)' },
{ question: '2nd Question (#2)', answer: '2nd Answer (#2)' }
]
},
{
id: 3,
questions: [
{ question: '1st Question (#3)', answer: '1st Answer (#3)' },
{ question: '2nd Question (#3)', answer: '2nd Answer (#3)' }
]
}
]
}
})
http://codepen.io/pespantelis/pen/QjoLLK
希望這有助於。
是的,我剛剛發現元素,並回來回答我自己的問題。看起來你得到的信用,而不是! :) – Chris