如何知道内部模板中当前迭代的数量foreach而不创建新变量来存储迭代数量?我无法使用 odoo 文档中的示例https://www.odoo.com/documentation/11.0/reference/qweb.html#reference-qweb \n例如:
$as_all\n the object being iterated over\n$as_value\n the current iteration value, identical to $as for lists and integers, but for mappings it provides the value (where $as provides the key)\n$as_index\n the current iteration index (the first item of the iteration has index 0)\n$as_size\n the size of the collection if it is available\n$as_first\n whether the current item is the first of the iteration (equivalent to $as_index == 0)\n$as_last\n whether the current item is the last of the iteration (equivalent to $as_index + 1 == $as_size), requires the iteratee\xe2\x80\x99s size be available\nRun Code Online (Sandbox Code Playgroud)\n
您可能错过了文档中的这一部分:
$as将被传递给的名称替换t-as
例子:
<t t-foreach="some_list" t-as="var_name">
<p> I'm in loop <t t-esc="var_name_index"/></p>
</t>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1445 次 |
| 最近记录: |