尝试使用 toastr 时出现错误 "toastr is not a function error"

Getting error "toastr is not a function error" when trying to use toastr

我想用toastr通知用户。我已按照 this 指南进行设置。但我收到错误消息:Uncaught TypeError: toastr is not a function。我查看了网络选项卡,文件正在正确加载。尝试使用 cdn 来确定。但没有运气。这就是我尝试使用它的方式:

    toastr('Are you the 6 fingered man?');

如演示中所示。关于我做错了什么有什么建议吗?

根据您链接的文档,应该这样使用:

toastr.info('Are you the 6 fingered man?')

您忘记调用函数 info()。

您需要按照以下方式使用 toastr 函数。

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?');