我正在尝试使用 dyntable 将数据写入 html 表。其中一个标题称为一年中的周
。在 JSON 文件中,名称也是一年中的周
(带有空格)。将 json 传递给 dynatable 时:
$('#week_table').dynatable({
dataset: {
records: [{"Week of year":"June 9, 2014 to June 15, 2014","a":0.0,"b":0.0,"c":0.0,"d":0.0,"e":1.0,"f":0.0},{"Week of year":"June 16, 2014 to June 22, 2014","a":0.0,"b":0.0,"c":5.0,"d":0.0,"e":16.0,"f":0.0}]
}});
并绘制到 html 表格:
<table id="week_table">
<thead>
<th>weekOfYear</th>
<th>Week of year</th>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
<th>e</th>
<th>f</th>
</thead>
<tbody>
</tbody>
</table>
表格对于 a
到 f
绘制得很好,但对于 weekOfYear
和 Week ofyear
都显示为未定义>。如何将 json 传递给包含空格的 dynatable?
最佳答案
这很奇怪。一开始它似乎也不适合我,但这里有一个包含您的数据的工作示例的链接。希望这有帮助
我变了
<th>weekOfYear</th>
至
<th>week</th>
关于javascript - 带空格的可动态 json 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26046428/