尝试使用toastr时,获取错误“toastr不是函数错误”

问题描述 投票:2回答:3

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

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

就像在演示中一样。关于我做错了什么的任何建议?

javascript jquery toastr
3个回答
5
投票

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

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

你忘了调用函数info()。


1
投票

您需要使用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})

1
投票

请使用带有信息,警告,成功,错误或选项的toastr。

toastr.info('Are you the 6 fingered man?');
© www.soinside.com 2019 - 2024. All rights reserved.