【发布时间】:2015-07-19 15:58:32
【问题描述】:
我有一个使用 Vue.js 绑定到数据的表。为每个玩家创建一行 (TR)。对于播放器中的每个报告,创建一个单元格 (TD)。这很好,但我想在当前报告 ID 的最后一个单元格中添加一个类。
所以...
<tr>
<td></td> //rptID = 1
<td></td> //rptID = 1
<td></td> //rptID = 1
<td class="lastOfRptID"></td> //rptID = 1
<td></td> //rptID = 2
<td class="lastOfRptID"></td> //rptID = 2
</tr>
这是我的示例代码:
var objArr = [
{
playerID: 1,
rpts: [
{rptID: 1,score: 1},
{rptID: 1,score: 2},
{rptID: 1,score: 3},
{rptID: 1,score: 4},
{rptID: 2,score: 1},
{rptID: 2,score: 2}
]
},
{
playerID: 2,
rpts: [
{rptID: 1,score: 5},
{rptID: 1,score: 6},
{rptID: 1,score: 7},
{rptID: 1,score: 8},
{rptID: 2,score: 3},
{rptID: 2,score: 4}
]
}
];
var vue = new Vue({
el: '#rpts',
data: {
title: 'reports',
reports: objArr
}
});
table {
width:99%;
height:20px;
}
td {
border:1px solid #000;
border-collapse: collapse;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/0.11.10/vue.min.js"></script>
<table id="rpts">
<tr v-repeat="reports">
<td v-repeat="rpts | orderBy 'rptID'">{{score}}</td>
</tr>
</table>
谢谢!
【问题讨论】:
标签: javascript css vue.js