template.js summation problem

 

The basic adaptation in this narrative do

<table>
    <tr>
        <Th> value </ th>
        <Th> value </ th>
         <Th> value </ th>
. . .
         <th> Total </ th>
    </tr>
</table>    

 

 

<Script ID = "tpl_data" type = "text / HTML"> 
    {{sumvalue = 0 }} // define variables
    {{each}}
    <td>{{$value.val}}</td>
    sumvalue sumvalue + = {{ $}} // value.val variable assignment
    {{/each}}
    <Td> {{sumvalue}} </ td> // display variable
</script>

 

The idea is: sumvalue define a variable, then the position value + = variable, {{sumvalue}} of the sum of the position display

 

Guess you like

Origin www.cnblogs.com/hkzw/p/11895810.html