【发布时间】:2021-06-11 14:02:35
【问题描述】:
我正在使用 NodeJS 并尝试使用 Toastr 实现错误消息。每当我尝试使用它时,我都会收到错误$.extend is not a function。我正在使用var toastr = require('toastr') 将toastr 导入文件,甚至尝试更改toastr.js 文件的一个组件(请参阅https://github.com/CodeSeven/toastr/issues/559),这会导致另一个错误jQuery needs a window in a document。我知道这个问题一定与 jQuery 有关,但无法解决。任何帮助将不胜感激!
谢谢!
【问题讨论】:
-
jQuery 是浏览器的 DOM 库,而不是服务器端的东西。你到底想在这里做什么?为什么要在节点中运行它?
-
只需为应用添加 toastr 错误通知。我收到的错误消息特别提到了 jQuery,但我不知道问题到底是什么。
-
不,你不明白,toastr是给浏览器的,node运行在server上。你为什么要在 server 上为 client 运行一些东西?
-
我同意你的看法 - 我可能不明白 :),但该应用程序是一个网络应用程序,我过去曾将 toastr 通知用于其他类似的项目。我只想在用户跳过表单中的必填字段、应用程序崩溃等时收到错误消息。您还有其他建议吗?
标签: javascript node.js npm node-modules toastr