首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用toastr时出现错误"toastr is not a function error“

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

Stack Overflow用户
提问于 2017-12-19 17:48:05
回答 3查看 12.7K关注 0票数 4

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

代码语言:javascript
复制
    toastr('Are you the 6 fingered man?');

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

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-12-19 17:51:56

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

代码语言:javascript
复制
toastr.info('Are you the 6 fingered man?')

您忘记调用函数info()。

票数 7
EN

Stack Overflow用户

发布于 2017-12-19 17:54:11

您需要使用toastr函数,如下所示。

请参阅documentation

代码语言:javascript
复制
// 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})
票数 3
EN

Stack Overflow用户

发布于 2017-12-19 17:56:17

请将toastr与info、warning、success、error或option一起使用。

代码语言:javascript
复制
toastr.info('Are you the 6 fingered man?');
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47884114

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档