我的AngularJS Web应用程序正尝试通过requirejs加载bootstrap4,popper和jquery,如下所示:
main.js
requirejs.config({
waitSeconds: 0,
baseUrl: "js/",
paths: {
'angular': 'lib/angular/1.7.8/angular',
'uiBootstrap': 'lib/angular-ui/3.0.6/ui-bootstrap-tpls-3.0.6',
'jquery': 'lib/jquery/3.2.1/jquery-3.2.1',
'popper': 'lib/popperjs/1.12.9/popper.min',
'bootstrap': 'lib/bootstrap/4.0.0/bootstrap.min'
},
shim: {
'angular': {deps: ['jquery'], exports: 'angular'},
'uiBootstrap': {deps: ['angular']},
'bootstrap': {deps: ['jquery', 'popper'], exports: 'bootstrap'}
}
});
requirejs([
"angular",
"bootstrap",
"app/initials"
],
function(angular) {
angular.bootstrap(window.document, ['initials']);
});
initials.js
define([
"angular",
"uiBootstrap"
],
function(angular) {
var initials = angular.module('initials', ['ui.bootstrap',
'ui.bootstrap.dropdown'
]);
return initials;
});
但是在检查浏览器控制台时发生以下错误。如何配置requirejs以适当地加载这些库?
require.min.js:34 GET http://localhost:8080/semfronteiras/popper.js net::ERR_ABORTED 404
require.min.js:8 Uncaught Error: Script error for: popper.js
http://requirejs.org/docs/errors.html#scripterror
at C (require.min.js:8)
at HTMLScriptElement.onScriptError (require.min.js:29)
require.min.js:8 Uncaught Error: Script error for: popper.js
jquery-3.2.1.js:3860 jQuery.Deferred exception: $(...).affix is not a function TypeError: $(...).affix is not a function
at HTMLDocument.<anonymous> (http://localhost:8080/semfronteiras/:111:35)
at mightThrow (http://localhost:8080/semfronteiras/js/lib/jquery/3.2.1/jquery-3.2.1.js:3583:29)
at process (http://localhost:8080/semfronteiras/js/lib/jquery/3.2.1/jquery-3.2.1.js:3651:12) undefined
jquery-3.2.1.js:3869 Uncaught TypeError: $(...).affix is not a function
at HTMLDocument.<anonymous> ((index):111)
at mightThrow (jquery-3.2.1.js:3583)
at process (jquery-3.2.1.js:3651)