我正在創建基於AngularJS,Breeze和RequireJS的單頁應用程序。在使用requirejs與AMD和Breeze合作設置AMD時,我遇到了Breeze對「q」的依賴問題。如果「Q」配置規則是小寫的,即使是在「中間」沒有明確的出口,微風給出了這樣的錯誤:angularjs和requirejs中的「Q」和「q」之間的區別
Uncaught Error: Unable to initialize Q. See https://github.com/kriskowal/q
"http://localhost:1498/Scripts/shared/breeze.js"breeze.js:1`
當需要配置的變化,從「Q」到「Q」的所有引用(即使沒有導出),代碼的作品。有誰知道爲什麼會發生這種情況?
這是工作需要配置:
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' ]
});
錯誤? http://community.phonegap.com/nitobi/topics/works_in_browser_not_on_phonegap_breeze_is_unable_to_initialize_q – zsong
看看這個病房 - http://stackoverflow.com/questions/17819991/angularjs-dataservice-using-breezejs-it-not-resolving-the- promise/17821353#17821353 - 應該有助於讓你知道爲什麼會發生這種情況,以及如何創建一個小型的工作 –
@PWKad,我認爲這個bug比requireJS或BreezeJS更適合Angular。沃德的例子是轉換承諾。我不認爲這涉及$ q或Angular的承諾。不同之處在於需要'q'和'Q' - 如果使用'q',它將不會加載 –