取消模块不确定。如何检测循环依赖性?

问题描述 投票:0回答:1
格式:

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
.

在一个小项目中很容易检测到此类循环依赖性。但是,如果有多个模块且它们的依赖性很复杂,我该如何轻松检测到此类缺陷?

sapui5 amd
1个回答
2
投票
    打开浏览器控制台,并确保可启用所有“冗长”logs.
  1. 用以下
  2. UI5config参数
  3. sap-ui-xx-debugModuleLoading

    run应用程序true

    带有值
    undefined
    .

  4. 在日志中,通过“循环检测到”过滤。

    循环检测到“ 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)以来,带有消息的实际错误:
    
    

    依赖性
    循环检测到:[...]sap.ui.modulesystem.

    
    
    

    在UI5图书馆开发

    仅由于UI51.91commit:e7daa82

    ),因此使用所需模块的
  5. API
initLibrary

library在较低的UI5版本中,由于循环依赖性而在引导程序过程中需要提早需要时,

"sap/ui/core/Core"模块可能会解散为

d83868e
分辨率

双检查是否在模块定义本身中确实需要对"sap/ui/core/Core"
undefined
的依赖性。
如果没有使用,请从列表中删除依赖项。
遵守文档中加载模块及其子主题的最佳实践。
与解决错误的Q&a相关的问答,必须加载使用Anonymous Define()调用的模块,然后加载require()调用”。 

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.