你的位置:首页 > 软件开发 > 网页设计 > Handlebars.js中集合(list)通过中括号的方式取值

Handlebars.js中集合(list)通过中括号的方式取值

发布时间:2017-02-15 12:00:10
有这么一个需求,在一个table中,tr是通过each取值,取出的值要与table标题相对应,如何实现?例如:<table> <thead> <tr>    {{#each 标题集合,值举例[name,sex...]}}      {{thi ...

有这么一个需求,在一个table中,tr是通过each取值,取出的值要与table标题相对应,如何实现?例如:

Handlebars.js中集合(list)通过中括号的方式取值Handlebars.js中集合(list)通过中括号的方式取值
<table> <thead>  <tr>    {{#each 标题集合,值举例[name,sex...]}}      {{this}}    {{/each}}    得到结果应是    <th>name</th>    <th>sex</th>  </tr> </thead> <tbody>  {{#each 内容集合,值举例[{name:'苏轼',sex:'男'},{name:'李清照',sex:'女'}...]}}   此时我想得到这样的数据,与标题想对应,该如何做呢?   <tr>     <td>苏轼</td>     <td>男</td>   </tr>   <tr>    <td>李清照</td>    <td>女</td>   </tr>  {{/each}} </tbody></table>

原标题:Handlebars.js中集合(list)通过中括号的方式取值

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。