0

我正在使用模板来填写表格:

模板:

<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';
}

我的身高在控制台中正确打印,但所有表格行相互重叠(好像没有设置顶部尺寸)。我绑定不正确吗?

4

1 回答 1

0

弄清楚了。

return (index() * 40) + ' px';

应该...

return (index() * 40) + 'px';

'px' 之前的间距搞砸了。

于 2012-06-11T19:10:55.663 回答