小编ash*_*143的帖子

如果"this"为空字符串,则句柄中的{{#each this}}不起作用

认为我的json是这样的:

{
    main: {
        "" : [{some_obj},{some_obj}]
    },
    secondary: {
        "key": [{some_obj},{some_obj}]
    }
}
Run Code Online (Sandbox Code Playgroud)

现在我的第一个#each将运行主要和辅助.

{{#each this}}
    -- This is for main and secondary --
    {{#each this}}
        -- This is for "" in case of main and "key" in case of secondary --
    {{/each}}
{{/each}} 
Run Code Online (Sandbox Code Playgroud)

如果"this"为空,我的嵌套#each将无效,如我的json中显示的"main"属性所示

javascript json handlebars.js

6
推荐指数
1
解决办法
782
查看次数

标签 统计

handlebars.js ×1

javascript ×1

json ×1