1
我希望根據條件顯示不同的HTML。如何比較車把中的值?
它似乎沒有比較這兩個值,它總是顯示第一個變體。我如何將預定義值與JSON中的原始值進行比較,以便它可以正確執行?
{{#each this}}
{{#each visits}}
<div class="row">
{{#if variable_from_json }}
<div class="col-lg-2 col-md-2 col-sm-2">
<i class="fa fa-home"></i>
</div>
{{else}}
<div class="col-lg-2 col-md-2 col-sm-2">
<i class="fa fa-plus symbol-hospital"></i>
</div>
{{/if}}
</div>
{{/each}}
{{/each}}
JS代碼
Handlebars.registerHelper('if', function (variable_from_json, options) {
if (variable_from_json === "M") {
return options.fn(this);
} else {
return options.inverse(this);
}
});
它不工作。 – xxCodexx
@HasmitRajput可以再次檢查一遍。我改變了格式 –