是否可以制作样式背景图像绑定?
我试过这段代码:
<div data-bind="foreach: itemList">
<div data-bind="style: { background-image: 'url:(temp.png)' }">some text</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我也尝试过backgroundImage,没有引号url,没有:后url,但它仍然无法正常工作.所有其他的,如绑定color或backgroundColor绑定工作完美.
我必须渲染一个具有可变列数的复杂表.在此示例中,列数取决于subRow的类型.例如,如果subRow是类型1,则它有3个动作,如果subRow类型是2,则它有4个动作.一起是7分的动作,所以我的表中有7列(+前两个,我渲染子行名称和类型(后代或子女等),但是这是不那么重要了.这前两列始终存在),因此7 + 2 = 9列.从树中添加子画(未在示例图片上绘制,因为它与此问题无关).
我使它在Internet Explorer中工作,因为我使用字体标记来挂钩淘汰模板,但是Mozilla Firefox和谷歌浏览器无法呈现这一点.
我的问题是:如何在表中绘制,没有字体标记?
我不会对任何其他标签有任何反对意见,只要Firefox可以渲染它,但我尝试了大部分标签,而你不做这个工作.
使用伪代码和图片,一切都会更清晰:
HTML:
<table>
<thead>
<tr>
<!--
So this is the table header. It defines number of columns in this table. Number of columns is variable, and this is the first part of the problem.
-->
<th class="tablehead" colspan="2">My List</th><th class="tablehead" data-bind="attr: { colspan: distinctActions().length }"> Actions </th><th class="tablehead"></th>
</tr>
</thead>
<tbody>
<tbody data-bind="template: { name: 'rowsTemplate', foreach: rowList } "></tbody>
</tbody>
Run Code Online (Sandbox Code Playgroud)
行模板:
<script type="text/x-jquery-tmpl" id="rowsTemplate">
<tr>
<td>
<button data-bind="click: save, …Run Code Online (Sandbox Code Playgroud)