尝试使用Toastr时出现错误“ toastr不是函数错误”

All*_*Est 2 javascript jquery toastr

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

    toastr('Are you the 6 fingered man?');
Run Code Online (Sandbox Code Playgroud)

如演示中所示。关于我在做什么错的任何建议吗?

Sha*_*nga 6

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

查看文档

// 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})
Run Code Online (Sandbox Code Playgroud)


tob*_*iso 5

根据您链接的文档,应按以下方式使用它:

toastr.info('Are you the 6 fingered man?')
Run Code Online (Sandbox Code Playgroud)

您忘记了调用函数info()。