作者:你是我最终的荒唐 | 来源:互联网 | 2023-01-05 10:35
Igotmain.jswiththissimplecode:我用这个简单的代码得到了main.js:usestrickt;require.config({paths
I got main.js with this simple code:
我用这个简单的代码得到了main.js:
'use strickt';
require.config({
paths: {
'angular' : 'libs/angular' ,
'angular-router' : 'libs/angular-route' ,
},
shim : {
'angular' : {
exports : 'angular'
},
'angular-router' : {
deps: ['angular']
}
}
});
require(['app'], function (mainApp) {
console.log(mainApp);
});
As you can see, I try to fetch app inside require callback. But all I got its undefined. Here what I got inside app.js file:
如您所见,我尝试在需要回调中获取应用程序。但我得到的都是未定义的。这是我在app.js文件中得到的:
define('mainApp', ['angular', 'angular-route'], function (angular) {
var app = angular.module('mainApp', ['ngRoute']);
console.log('should be fired from app.js');
return app;
});
So the question: Function argument 'mainApp' as undefined inside main.js callback seems logical because console.log() inside app.js doesnt shoot. Can somebody tell me what is wrong with it?
所以问题:函数参数'mainApp'在main.js回调中未定义似乎是合乎逻辑的,因为app.js中的console.log()不会发生。有人能告诉我它有什么问题吗?
1 个解决方案