在带有句柄的迭代函数(每个)中传递参数类型对象

pass an argument type object in an iterate function (each) with handlears

本文关键字:参数 对象 类型 每个 句柄 函数 迭代      更新时间:2023-09-26

我想使用车把将对象作为函数中的参数传递到每个函数中,但是传递的对象在循环函数中未定义,而在"每个"之外一切都很好

{{#each sits}}
<tr>
      <td class="content content-center">{{@key}}</td>
      <td class="content ar">{{getMaxFormula terms sits 'd' sits.name}}</td>
</tr>
{{'each}}

在我的 JSON 文件中:

{
"terms": [
  {
     "evt": "d",
     "cap": 50000,
     "type": "d"
  }
  ],
"sits": {
  "2015": {
     "d": 50000,
     "i": 0,
     "a": 0,
     "cumul": 3491.637,
     "premium": 5000,
     "com": -1500,
     "term": -77.151,
     "taxEco": 1500
  },
  "2016": {
     "d": 46508.363,
     "i": 0,
     "a": 0,
     "cumul": 9131.576,
     "premium": 6000,
     "com": -550,
     "term": -89.622,
     "taxEco": 1800
  }
 }
}
{{#each sits as |value key|}}
    <tr>
      <td class="content content-center">{{key}}</td>
    </tr>
{{/each}}

但是这里 sits.name 什么:

<td class="content ar">{{getMaxFormula terms sits 'd' sits.name}}</td>