gpt4 book ai didi

jquery - AngularJS 中未定义 Toastr

转载 作者:行者123 更新时间:2023-12-03 22:08:49 25 4
gpt4 key购买 nike

我正在做教程,这部分是关于实现登录,这应该给出有关登录成功的气球

angular.module("app").value("mvToastr", toastr);

angular.module("app").factory("mvNotifier", function(mvToastr) {
return {
notify: function(msg) {
mvToastr.success(msg);
console.log(msg);
}
}
});

我明白了,但我有点不明白。所有 .js 文件似乎都已加载。请告诉我问题出在哪里,谢谢。

TypeError: Cannot call method 'extend' of undefined
at getOptions (http://localhost:3030/vendor/toastr/toastr.js:282:14)
at Object.success (http://localhost:3030/vendor/toastr/toastr.js:68:17)
at Object.notify (http://localhost:3030/app/common/mvNotifier.js:6:22)
at http://localhost:3030/app/account/mvNavBarLoginCtrl.js:8:28
at wrappedCallback (http://localhost:3030/vendor/angular/angular.js:11033:81)
at wrappedCallback (http://localhost:3030/vendor/angular/angular.js:11033:81)
at http://localhost:3030/vendor/angular/angular.js:11119:26
at Scope.$eval (http://localhost:3030/vendor/angular/angular.js:12045:28)
at Scope.$digest (http://localhost:3030/vendor/angular/angular.js:11871:31)
at Scope.$apply (http://localhost:3030/vendor/angular/angular.js:12151:24)

angular.js:9503

最佳答案

查看toastr sources看起来像 getOptions() 调用了 jQuery 的 $.extend() 方法。

Toastr 依赖于 jQuery,来自 github 自述文件的第一行:

toastr is a Javascript library for non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.

只需在您的主视图 html 中包含 jquery 即可。

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

关于jquery - AngularJS 中未定义 Toastr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22210581/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com