sap.ui.define([ // in my/ModuleA.js
// "...",
"./ModuleB",
], function (/*...,*/ModuleB) {
// ... ModuleB is undefined here
return/*...*/;
});
sap.ui.define([ // in my/ModuleB.js
// "...",
"./ModuleA"
], function (/*...,*/ModuleA) {
// ... ModuleA is undefined here
return/*...*/;
});
构建并运行应用程序后,检查生成的Component-preload.js
表明
ModuleB
中的
my/ModuleA.js
参数或
ModuleA
中的
my/ModuleB.js
参数为
undefined
.。 在一个小项目中很容易检测到此类循环依赖性。但是,如果有多个模块且它们的依赖性很复杂,我该如何轻松检测到此类缺陷?
用以下
sap-ui-xx-debugModuleLoading
run应用程序true
带有值
undefined
.。
循环检测到:[...]sap.ui.modulesystem. 在UI5图书馆开发循环检测到“ my/moduleb.js”和'my/modulea.js',返回“ my/modulea.js' - sap.ui.modulesystem” 在“ my/modulea.js”和'my/moduleb.js'之间检测到cycle,返回“ my/moduleb.js” -sap.ui.modulesystem
和自undefined
(UI5 1.121)以来,带有消息的实际错误: 依赖性
),因此使用所需模块的仅由于UI51.91(commit:
e7daa82
initLibrary
library在较低的UI5版本中,由于循环依赖性而在引导程序过程中需要提早需要时,"sap/ui/core/Core"
模块可能会解散为
d83868e
。
分辨率
双检查是否在模块定义本身中确实需要对"sap/ui/core/Core"
或undefined
的依赖性。 如果没有使用,请从列表中删除依赖项。
遵守文档中加载模块及其子主题的最佳实践。
与解决错误的Q&a相关的问答,必须加载使用Anonymous Define()调用的模块,然后加载require()调用”。