【问题标题】:Html, how to import / use toastr.jsHtml,如何导入/使用 toastr.js
【发布时间】:2016-02-13 21:18:13
【问题描述】:

这里有个小问题。我认为解决方案很简单,我只是在监督一些事情。

所以,我的问题是,我试图在我的网页上使用 toastr.js。 到目前为止我得到了什么:

<link href="{% static "flat/css/toastr.min.css" %}" rel="stylesheet"/>

(显然指向 toastr.min.css 文件)和

<script src="{% static "flat/js/toastr.js" %}" ></script>

(指向 toastr.js 文件)。

现在就在&lt;/body&gt; 之前,我有

<script type="text/javascript">
    $(document).ready(function() {
        toastr.options={"closeButton": false,"debug": false,"newestOnTop":  true,"progressBar": true,"positionClass": "toast-bottom-full-width","preventDuplicates": false,"onclick": null,"showDuration": "300","hideDuration": "1000","timeOut": "5000","extendedTimeOut":"1000","showEasing": "swing","hideEasing": "linear","showMethod": "fadeIn","hideMethod": "fadeOut"};
        toastr[success]("Message will come here", "Title");}
    );
</script>

所以,我想使用 toastr 在页面加载时显示通知。 我该如何做到这一点?

【问题讨论】:

  • 现在发生了什么?没有?有任何错误吗?不应该是toastr.success("message will come here" ,"title");吗?
  • @putvande 不,我完全没有错误
  • @putvande 和我已经尝试过 toast.success,但结果完全一样

标签: javascript html toastr


【解决方案1】:

您正在使用一个未定义的变量 success,当它以 [] 表示法使用时应该是一个字符串,或者只是一个以点表示法表示的属性名称

试试

toastr['success']("Message will come here", "Title");

或者

toastr.success("Message will come here", "Title");

【讨论】:

  • 不,他们都没有解决问题。
  • 我应该使用toastr.success("Message will come here", "Title");还是$(document).ready(function() { toastr.success("Message will come here", "Title"); )}
  • 使用内部准备好,如问题所示。查看浏览器开发工具网络以确保 css 和 js 资源都在加载
  • 是的,我认为问题在于 toastr.js 文件没有加载!
  • 你说没有错误,但那是不可能的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-07-28
  • 1970-01-01
  • 2022-11-19
  • 1970-01-01
  • 1970-01-01
  • 2016-12-25
  • 2020-05-19
相关资源
最近更新 更多