【发布时间】:2020-02-16 22:09:22
【问题描述】:
我正在尝试使用 Toastr JS,最初我无法弄清楚为什么它不会出现,但它确实会出现(通过将 Timeout 更改为 10 分钟并查看源代码来解决)但它是不可见的,我不知道为什么。它出现在所有内容下方而不是右上角。
我的模板代码
{% block javascript %}
{% if messages %}
{% for message in messages %}
{% if message.tags == 'success'%}
<script> toastr.success("{{ message }}")</script>
{% elif message.tags == 'info' %}
<script> toastr.info("{{ message }}")</script>
{% elif message.tags == 'warning' %}
<script> toastr.warning('{{ message }}")</script>
{% elif message.tags == 'error' %}
<script>
toastr.options = {
closeButton: false,
debug: false,
newestOnTop: false,
progressBar: true,
positionClass: "toast-top-right",
preventDuplicates: false,
onclick: null,
showDuration: "9000",
hideDuration: "1000",
timeOut: "0",
extendedTimeOut: "1000",
showEasing: "swing",
hideEasing: "linear",
showMethod: "fadeIn",
hideMethod: "fadeOut"
}
toastr.error("{{ message }}")
</script>
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}
【问题讨论】:
标签: javascript html django bootstrap-4 toastr