不显示弹出消息框

时间:2019-08-10 05:46:26

标签: javascript django python-3.x

我想要在用户注册后显示一条消息,指示用户已成功注册,对于注销和登录,该消息相同

该消息已显示,但没有弹出,我认为问题出在脚本方面。请帮忙!

base.hmtl

{% if messages %}
  {% for message in messages %} 
    {% if message.tags == 'success' %}
     <script>M.toast({html: " {{message}}, classes:"blue rounded",displayLenght:2000});</script>
     {% elif message.tags == 'info' %}
     <script>M.toast({html: " {{message}}, classes:"blue rounded",displayLenght:2000});</script>
     {% elif message.tags == 'warning' %}
     <script>M.toast({html: " {{message}}, classes:"blue rounded",displayLenght:2000});</script>
     {% elif message.tags == 'error' %}
     <script>M.toast({html: " {{message}}, classes:"blue rounded",displayLenght:2000});</script>
     {% endif %}
  {% endfor %}
{% endif %}

enter image description here

1 个答案:

答案 0 :(得分:1)

您在邮件模板后错过了", 请尝试

{% if messages %}
  {% for message in messages %} 
    {% if message.tags == 'success' %}
     <script>M.toast({html: " {{message}}", classes:"blue rounded",displayLenght:2000});</script>
     {% elif message.tags == 'info' %}
     <script>M.toast({html: " {{message}}", classes:"blue rounded",displayLenght:2000});</script>
     {% elif message.tags == 'warning' %}
     <script>M.toast({html: " {{message}}", classes:"blue rounded",displayLenght:2000});</script>
     {% elif message.tags == 'error' %}
     <script>M.toast({html: " {{message}}", classes:"blue rounded",displayLenght:2000});</script>
     {% endif %}
  {% endfor %}
{% endif %}