Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 访问把手中的父作用域属性时出错_Javascript_Handlebars.js_Templating_Handlebarshelper - Fatal编程技术网

Javascript 访问把手中的父作用域属性时出错

Javascript 访问把手中的父作用域属性时出错,javascript,handlebars.js,templating,handlebarshelper,Javascript,Handlebars.js,Templating,Handlebarshelper,我正在使用一个把手模板,每个模板都嵌套有和if助手。看起来像这样 {{each resultSet}} ...some html... {{each segment}} {{if @index}} ---some html-- {{../someParentValue}} {{/if}} {{/each}} {{/each}} 当我访问此someParentValue时,我在控制台“未捕获类型错误:无

我正在使用一个把手模板,每个模板都嵌套有
if
助手。看起来像这样

{{each resultSet}}
   ...some html...
   {{each segment}}
       {{if @index}}
            ---some html--
            {{../someParentValue}}
       {{/if}}
   {{/each}}
{{/each}}
当我访问此
someParentValue
时,我在控制台
“未捕获类型错误:无法读取未定义的属性“1”

如果我在路径中添加另一个级别,即
。/../someParentValue
,以访问每个结果集的范围,那么我将得到错误
“Uncaught TypeError:无法读取未定义的属性“2”


我不确定这会有什么问题,因为在检查结果集时,我可以看到该结果集中的每个项目都有我试图访问的属性。

在Handlebar 3.0中新增,可以从支持帮助人员处接收命名参数

{{each resultSet as |rs}}
   ...some html...
   {{each segment as |seg}}
       {{if @index}}
            ---some html--
            {{rs.someResultSetProperty}}
       {{/if}}
   {{/each}}
{{/each}}
希望这有帮助