我正在创建一个基于 AngularJS、Breeze 和 RequireJS 构建的单页应用程序。在使用 requirejs 设置 AMD 以与 Angular 和 Breeze 配合使用时,我遇到了 Breeze 对“q”的依赖问题。如果“q”的配置规则是小写,即使“shim”中没有显式导出,Breeze也会给出以下错误:
Uncaught Error: Unable to initialize Q. See https://github.com/kriskowal/q
"http://localhost:1498/Scripts/shared/breeze.js"breeze.js:1`
当 require config 将所有引用从“q”更改为“Q”(即使没有导出)时,代码将起作用。有谁知道为什么会发生这种情况?
这是working需要配置:
require.config({
baseUrl: '../Scripts',
paths: {
angular: 'shared/angular',
bootstrap: 'shared/ui-bootstrap',
dropdowns: 'app/directives/dropdowns',
employeeApp: 'app/modules/employeeModule',
controllers: 'app/controllers',
dates: 'app/directives/dates',
jquery: 'shared/jquery',
Q: 'shared/q',
breeze: 'shared/breeze',
config: 'app/services/config',
model: 'app/services/model',
dataservice: 'app/services/dataservice',
expenseInfo: 'app/services/expenseInfo'
},
shim: {
'angular': { 'exports': 'angular' },
'bootstrap': { deps: ['angular'] },
//'q': { 'exports': 'q' },
'breeze': { deps: ['Q', 'jquery'], 'exports': 'breeze' }
},
priority: [ 'angular', 'bootstrap', 'dropdowns', 'jquery',
'Q', 'breeze', 'employeeSearch', 'dates' ]
});