我当前使用的是最新版本的breezejs(1.4.2),其中包含requirejs和淘汰赛。我有以下要求配置...
require.config({
paths:
{
"jquery": "../Scripts/jquery-1.10.2.min", //using jquery 1.x for older browsers
"bootstrap": "../Scripts/bootstrap.min",
"knockout": "../Scripts/knockout-2.3.0",
"knockoutMapping": "../Scripts/knockout.mapping-latest",
"toastr": "../Scripts/toastr.min",
"Q": "../Scripts/Q.min",
"es5-shim": "../Scripts/es5-shim.min",
"es5-polyfill": "../Scripts/es5-polyfill",
"breeze": "../Scripts/breeze.min",
"kendo": "../Scripts/kendo/2013.2.716/kendo.web.min",
"knockoutKendo": "../Scripts/knockout-kendo.min",
"globalize": "../Scripts/globalize/globalize",
"globalize-au": "../Scripts/globalize/cultures/globalize.culture.en-AU"
},
shim:
{
"jquery": { exports: "$" },
"knockout": { deps: ["jquery"] },
"Q": { deps: ["jquery", "knockout"] },
"breeze": { deps: ["knockout", "jquery", "Q", "es5-shim", "es5-polyfill"] },
"globalize-au": { deps: ["globalize"] },
"bootstrap": { exports: "Bootstrap", deps: ["jquery"] },
"kendo": { deps: ["jquery"] },
"knockoutKendo": { deps: ["knockout", "kendo"] },
"knockoutMapping": { deps: ["knockout"] }
}
});
查看网络通信量,在上面列出的所有依赖项之后加载breeze.min.js,但我仍然得到breeze查询返回的常规JSON对象,而不是我期望的那样剔除可观察的属性。
如果我在requirejs之外添加敲除脚本,并在微风脚本之前使用标准脚本标签,则一切正常。因此,这确实暗示了我无法解决的依赖项和加载顺序首选项问题。
这里是一个示例查询,我正在使用它来返回微风实体。注意,我当前所有的微风查询都返回具有不可观察属性的实体:
// Look for the log in manager"s cache first
// Fetch from the database if not found in the cache
return manager
.fetchEntityByKey("SqlLog", sqlLogId, true)
.then(function (data)
{
log("Retrieved [SQL DETAILS] from remote data source", data, true);
// using entity values here as breeze not returning observables.
sqlText(data.entity.SqlText);
parameters(data.entity.Parameters);
exceptionMessage(data.entity.ExceptionMessage);
})
.fail(queryFailed);
自己打了那个人。快速的答案是轻风坚持只寻找“ ko”,因此您可以在配置中使用它。
技术原因是微风明确地寻找“ ko”。要查找所有微风,需要在源代码中搜索“ requireLib”(不是整个单词)。
[Breeze始终首先寻找全局变量,并且因为淘汰赛的全局变量是'ko',所以breeze一直在寻找它。
因此,在RequireJS之外加载基因剔除时,不是时间问题,而是解决问题的“ ko” var名称可用性。
在我的相关答案Difference between "Q" and "q" in angularjs and requirejs中查看更多详细信息