django前端for遍历去除尾部顿号分号
原
<td align="right">参运车辆:</td>
<td>
{% for foo in car %}
{{ foo.file_car_tag_s_eaa }}、
{% endfor %}
</td>
改
<td align="right">参运车辆:</td>
<td>
{% for foo in car %}
{{ foo.file_car_tag_s_eaa }}{% if not forloop.last %}、{% endif %}
{% endfor %}
</td>

本文介绍了一种在Django前端使用for循环遍历时去除最后一个元素尾部的顿号的方法,通过判断当前项是否为最后一项来决定是否显示顿号。
1万+

被折叠的 条评论
为什么被折叠?



