Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
444 views
in Technique[技术] by (71.8m points)

javascript - 如何通过把手中的索引访问访问数组项?(How do I access an access array item by index in handlebars?)

I am trying to specify the index of an item in an array within a handlebars template:(我试图在把手模板中指定数组中项目的索引:)

{ people: [ {"name":"Yehuda Katz"}, {"name":"Luke"}, {"name":"Naomi"} ] } using this:(使用这个:) <ul id="luke_should_be_here"> {{people[1].name}} </ul> If the above is not possible, how would I write a helper that could access a spefic item within the array?(如果以上是不可能的,我如何编写一个可以访问数组中的spefic项的帮助器?)   ask by lukemh translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this:(试试这个:)

<ul id="luke_should_be_here"> {{people.1.name}} </ul>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[1] html - How to create even cell spacing within a

2.1m questions

2.1m answers

60 comments

56.8k users

...