使用Flask flash(&#39; hello&#39;),<script> alert({{message}})</script>不起作用

时间:2018-06-11 14:32:41

标签: python flask jinja2

我在python文件中使用flash('hello'),在HTML文件中使用相关部分:

{% with messages = get_flashed_messages() %}
  {% if messages %}

    <p>{{messages[0]}}</p>
    <script> alert( {{messages[0]}} )</script>
    <script> alert('aaaaaaaa')       </script> 

  {% endif %}
{% endwith %}

窗口警告aaaaaaaa显示,并且[&#39; hello&#39;]显示在网页上。 但是没有窗口警告你好。 我不知道为什么它在标记<p>中有效,但在标记<script>中失败, 我的javascript很差。有谁能为我解释一下吗?

BTW python3.6,烧瓶1.0.2

0 个答案:

没有答案