【问题标题】:Toastr JS appears in source code but is invisibleToastr JS 出现在源代码中但不可见
【发布时间】: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


    【解决方案1】:

    问题出在

     <link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" rel="text/css" media="all">
    

    需要替换为

    <link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" rel="stylesheet" media="all">
    

    附加:使用 Toastr JS 时必须始终使用标准 JQUERY(最低版本的 Jquery 与 Toastr 不兼容)

    【讨论】:

    • 这两个网址似乎都在使用最低版本
    • 这个问题是 ``` rel="text/css" ``` 独有的,但也必须始终使用标准 jquery,min 版本与 toastr 不兼容。
    猜你喜欢
    • 2015-12-13
    • 1970-01-01
    • 2016-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    • 1970-01-01
    • 2022-10-01
    相关资源
    最近更新 更多