{% if not notfication in alert %}
<div style=" background: no-repeat; ">
<div class="">
<span>None</span>
</div>
</div>
{% else %}
<div class="marquee-area">
<div class="marquee-wrap">
{% for notfication in alert %}
<span>{{ notfication.title }}</span>
{% endfor %}
</div>
</div>
{% endif %}
当我尝试测试它时,无论是否有数据,我都没有收到她的文字
检查
alert
的真实性:
{% if not alert %}
<div style=" background: no-repeat; ">
<div class="">
<span>None</span>
</div>
</div>
{% else %}
<div class="marquee-area">
<div class="marquee-wrap">
{% for notification in alert %}
<span>{{ notification.title }}</span>
{% endfor %}
</div>
</div>
{% endif %}
然而,通常人们使用正逻辑:
{% if alert %}
<div class="marquee-area">
<div class="marquee-wrap">
{% for notification in alert %}
<span>{{ notification.title }}</span>
{% endfor %}
</div>
</div>
{% else %}
<div style=" background: no-repeat; ">
<div class="">
<span>None</span>
</div>
</div>
{% endif %}