如何在每个循环把手js中添加另一个值

时间:2018-09-07 12:36:53

标签: javascript node.js handlebars.js

<ul id="sortable">{{#each put.images}}
    <li class="imageSort" id="{{this}}">
      <div class="perant_edit_img">
      <span class="del_img_edit">
      <i class="fa fa-times"></i>
      </span>
      <img src="/uploads/items/{{this}}" alt="First slide">
      </div>
      </li>
    {{/each}}
</ul>

我需要将此值添加到每个{{put.dirImg}}中,然后添加方式吗?

{{put.dirImg}}仅在每个外部打印,但每个内部都不打印!

1 个答案:

答案 0 :(得分:1)

尝试一下。

<ul id="sortable">
  {{#each put.images}}
    <li class="imageSort" id="{{this}}">
      <div class="perant_edit_img">
      <span class="del_img_edit">
      <i class="fa fa-times"></i>
      </span>
      <img src="/uploads/items/{{../dirImg}}{{this}}" alt="First slide">
      </div>
      </li>
    {{/each}}
</ul>