【发布时间】:2018-06-12 15:20:43
【问题描述】:
我不知道 qweb 中 if-else 的正确语法是什么。
<t t-if="origin != l.origin">
<td>foo</td>
<t t-else/>
<td>bar</td>
</t>
这里有什么问题?
【问题讨论】:
我不知道 qweb 中 if-else 的正确语法是什么。
<t t-if="origin != l.origin">
<td>foo</td>
<t t-else/>
<td>bar</td>
</t>
这里有什么问题?
【问题讨论】:
你必须使用<t t-else=""><td>bar</td></t>,看看documentation。
【讨论】:
在上面的行中,你已经关闭了 else 标签 <t t-else/>
你应该这样写:
<t t-if="origin != l.origin">
<td>foo</td>
</t>
<t t-else="">
<td>bar</td>
</t>
【讨论】:
你也可以试试 t-elif :
<t t-if="origin != l.origin">
<td>foo</td>
</t>
<t t-elif="">
<td>bar</td>
</t>
【讨论】:
对于那些正在寻找类似问题的人,请注意,t-else 仅在 Odoo 10 中添加。
因此,对于 t-if 的否定。
<t t-if="condition">
</t>
<t t-if="not condition">
</t>
对于 Odoo >= 10,
<t t-if="condition">
</t>
<t t-else="">
</t>
【讨论】: