我想在if语句中按键获取元素的值 .
Example:
作品:
{{ example[5] }}
不起作用:
{% if example2 is example[5] %} something ... {% endif %}
Exception thrown:
意外的标记“标点符号”值“[”(“语句块结束”预期)
非常感谢你
亲切的问候
代替
尝试将'is'更改为'=='
{% if example2 == example[5] %} something ... {% endif %}
也许您应该使用 attribute 函数来获取对象或数组值 . This link可以帮到你
attribute
2 回答
代替
尝试将'is'更改为'=='
也许您应该使用
attribute
函数来获取对象或数组值 . This link可以帮到你