我有一个JArray,它包含一个对象数组。我使用handlebars.net来绑定模板中的数据。
在getReportDetails变量中,我得到了以下格式的对象数组
[
{
"index": 1,
"Name": "Adam",
},
{
"index": 2,
"Name": "Sdam",
}
];
var template = Handlebars.Compile(source);
_logger.Info(getReportDetails);
var getdata = template(getReportDetails);
<tbody>
{{#each getReportDetails}}
<tr>
<td>{{Name}}</td>
</tr></tbody>在getdata变量中,数据不是绑定的。我做错了什么?
发布于 2022-11-22 14:33:51
数组是数据对象的根,所以应该使用#each this。
<tbody>
{{#each this}}工作实例:
var list = new List<X>() { new X() { Id=1 }, new X() { Id = 2} };
var template = Handlebars.Compile("{{#each this}} xxx {{Id}} {{/each}}");https://stackoverflow.com/questions/74534161
复制相似问题