Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是灰尘模板的新手,知道这个问题的解决方案
我想遍历此视图上下文并仅获取亲戚和朋友数组的第一项。
{ Relative: "ravi", friends: [ { name: "Moe", age: 37 }, { name: "Larry", age: 39 }, { name: "Curly", age: 35 } ] }
您可以使用@eqDust 的 LinkedIn 分支中提供的帮助程序来完成。
@eq
{Relative}{~n} {#friends} {@eq key=0 value="{$idx}" type="number"} {name} {age} {/eq} {/friends}
您仍然循环遍历整个数组,但如果数组索引 ( $idx) 为,则仅输出名称和年龄0。
$idx
0