[英]Getting error “toastr is not a function error” when trying to use toastr
I want to use toastr to notify the user. 我想使用toastr来通知用户。 I have followed this guide to set it up. 我已按照本指南进行设置。 But I get the error message: Uncaught TypeError: toastr is not a function
. 但是我收到错误消息: Uncaught TypeError: toastr is not a function
。 I have looked at the network tab and the files are loading properly. 我查看了网络选项卡,文件正确加载。 Tried with a cdn to be sure. 尝试用cdn来确定。 But no luck. 但没有运气。 This is how I tried to use it: 这就是我尝试使用它的方式:
toastr('Are you the 6 fingered man?');
As in the demo. 就像在演示中一样。 Any suggestions about what I am doing wrong? 关于我做错了什么的任何建议?
According to the documentation you linked, it should be used like this: 根据您链接的文档,它应该像这样使用:
toastr.info('Are you the 6 fingered man?')
You forgot to call the function info(). 你忘了调用函数info()。
You need to use toastr functions as per below. 您需要使用toastr函数,如下所示。
See documentation 见文档
// Display a warning toast, with no title
toastr.warning('My name is Inigo Montoya. You killed my father, prepare to die!')
// Display a success toast, with a title
toastr.success('Have fun storming the castle!', 'Miracle Max Says')
// Display an error toast, with a title
toastr.error('I do not think that word means what you think it means.', 'Inconceivable!')
// Immediately remove current toasts without using animation
toastr.remove()
// Remove current toasts using animation
toastr.clear()
// Override global options
toastr.success('We do have the Kapua suite available.', 'Turtle Bay Resort', {timeOut: 5000})
请使用带有信息,警告,成功,错误或选项的toastr。
toastr.info('Are you the 6 fingered man?');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.