循环遍历Handlebars.js中的多维数组 [英] Looping through a multidimensional array in Handlebars.js

查看:252
本文介绍了循环遍历Handlebars.js中的多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让服务器传回这个JSON,我不知道如何在Handlebars中循环一个二维数组。

I have the server passing back this JSON and I'm not sure how to loop through a 2-dimensional array in Handlebars.

"userSurvey":[[1],[2],[3]]

I知道使用 {{#each userSurvey}} 但是我如何在 usersurvey 对象中进行数组操作?

I know to use {{#each userSurvey}} but then how would I go about do the arrays inside the usersurvey object?

推荐答案

你必须循环2次:

{{#each userSurvey}}
  {{#each this}}
    {{ this }}
  {{/each}}
{{/each}}

这篇关于循环遍历Handlebars.js中的多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆