首页 > 解决方案 > 如何在车把模板中获取数组的索引值

问题描述

function getFruitsData()
{
var fruit=[];
fruit.push("Apple");
fruit.push("Mango");
fruit.push("Grapes");
fruit.push("Orange");

return fruit;
}

我发送到控制台中的模板的水果数据

在此处输入图像描述

现在我需要像这样展示 Fruits[0] 这将导致 >>> Apple

现在在模板中我使用这个不起作用

{{#each someOtherList}}

{{this.[Fruits].@index.this}} >> not working
{{Fruits.@index.this}} >> not working
{{Fruits.[@index]}} >> not working

{{/each}}

我不需要迭代所有数据我只需要根据我通过的索引的特定数据

标签: javascripthandlebars.js

解决方案


推荐阅读