我正在尝试将Toastr
与angular js
一起使用,但会收到以下错误。我按预期包含了jquery.js
文件。
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"
错误讯息:
angular.js:11594 TypeError:无法读取未定义的属性'extend'
at m(toastr.js:474)
在Object.o [as info](toastr.js:474)
在ProductTableController.showAddToCartToast(productTable.directive.js:207)
在ProductTableController.addToCart(productTable.directive.js:159)
在angular.js:12332
在f(angular.js:22949)
at a。$$ ChildScope。$$ ChildScope。$ eval(angular.js:14383) at a。$$ ChildScope。$$ ChildScope。$ apply(angular.js:14482) 在HTMLButtonElement。 (angular.js:22954) 在HTMLButtonElement.dispatch(jquery.js:4670)(匿名函数)@ angular.js:11594(匿名函数)@ angular.js:8544 $ apply @ angular.js:14484(匿名函数)@ angular.js:22954dispatch @ jquery.js:4670r.handle @jquery.js:4338
知道什么是错的吗?
感谢。
答案 0 :(得分:2)
我认为你在angular.js之后包含了Jquery文件。将您的Jquery文件移到Angularjs文件上方。
例如
add_action( 'wp_enqueue_scripts', 'sreub_enqueue_styles', 50);
答案 1 :(得分:0)
您可以使用angular-toastr库
安装:bower install angular-toastr
包含依赖:angular.module('app', ['ngAnimate', 'toastr'])
在控制器中使用:
app.controller('foo', function($scope, toastr) {
toastr.success('Hello world!', 'Toastr fun!');
});