【发布时间】:2020-04-22 16:10:52
【问题描述】:
我正在向具有分支详细信息的 jsrender 模板发送 ajax 响应中的对象 branchData。
branchData: Array(2)
0: {name: "M13", displayName: "Abc", url: null}
1: {name: "M01", displayName: "Xyz", url: null}
与
var helper = {
branchHoursText: "Teléfono y Horarios"
phoneText: "Teléfono"
hoursText: "Horario"
closedText: "CERRADA"
inventory: {M01: "0", M13: "1", M11: "0", M10: "0", M21: "0"}
}
$(".branchInfo").html(branchTemplate.render(response, helpers));
我在模板中使用以下代码。
{{for branchData}}
{{:displayName}}
{{props ~inventory}}
{{/props}}
{{/for}}
如果 branchData.name == inventory.key,我想显示该分支的库存。类似的东西
{{props ~inventory}}
{{if key === name}}
{{>prop}}
{{/if}}}
{{/props}}
请帮忙!!
【问题讨论】: