UI5 Control lazy load mechanism

81 阅读1分钟
  • Create dummy constructor which loads the class on demand
  • this is a derived ( generated ) file. Change should be done in the underlying source files only(*.control, *.js) or they will be lost after the next generation.

当UI需要实例化一个js 类的instance时,
clipboard1
首先会call jQuery.sap.require方法去加载该类:
clipboard2
requireModule方法输入的是该类对应的js文件的相对路径:

clipboard3
clipboard4
sScript内容如下:
clipboard5
触发对应的TileBase module的加载:
clipboard6
通过getResourcePath获得module对应的js文件路径,然后通过AJAX想server发起请求进行加载:
clipboard7