Handlebars.js-使用变量键访问对象值 [英] Handlebars.js - Access object value with a variable key
本文介绍了Handlebars.js-使用变量键访问对象值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正在寻找一种途径来实现这一目标:
Looking for a way to access to achieve this:
{{#each someArray}}
{{../otherObject.[this]}}
{{/each}}
如何计算this
的值,然后将其作为对象otherObject
的键引用?
How do I evaluate the value of this
and then reference it as a key to my object otherObject
?
推荐答案
通过查找: http://handlebarsjs.com/builtin_helpers. html#lookup
{{#each someArray}}
{{lookup ../otherObject this}}
{{/each}}
这篇关于Handlebars.js-使用变量键访问对象值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文