我正在使用模板来填写表格:
模板:
<tr data-bind="click: pressedItem, style: { top: getHeightFromIndex($index), position: 'absolute' }">
<td class="resultCell">
<div class="resultItem" data-bind="attr: { id: $root.key }, html: formattedName" style="float: left"></div>
</td>
</tr>
在视图模型中:
getHeightFromIndex = function(index) {
console.log("Height: " + (index() * 40) + " px");
return (index() * 40) + ' px';
}
我的身高在控制台中正确打印,但所有表格行相互重叠(好像没有设置顶部尺寸)。我绑定不正确吗?