SAP UI5应用入口App.controller.js是如何被UI5框架加载的?
2023-09-14 09:02:42 时间
首先在UI5应用的manifes.json里,定义了UI5应用的入口视图为App:
![](https://user-images.githubusercontent.com/5669954/59995891-4abc8480-968b-11e9-889b-93547c6a4fd2.png)
调试器里的pending数组的两个元素:
![](https://user-images.githubusercontent.com/5669954/59995880-48f2c100-968b-11e9-9157-ced6481fce99.png)
实际上对应了我在App.controller.js里定义的两个依赖:
![](https://user-images.githubusercontent.com/5669954/59995882-48f2c100-968b-11e9-9de5-e3c02ff30120.png)
而aModules数组里的两个对象,就是BaseController和JSONModel模块加载后的实例:
![](https://user-images.githubusercontent.com/5669954/59995883-48f2c100-968b-11e9-92b1-f7e6af539025.png)
有经验的开发人员从这些函数列表bindProperty, bindTree, dataLoaded,getJSON等就能得知这个实例是JSONModel的实现。
![](https://user-images.githubusercontent.com/5669954/59995884-498b5780-968b-11e9-809a-51ae5dd85873.png)
这个注释写的比较清楚,如果factory函数返回不为false的值,则该值需要被赋到module的exported字段去。
from https://github.com/amdjs/amdjs-api/blob/master/AMD.md
// “If the factory function returns a value (an object, function, or any value that coerces to true),
// then that value should be assigned as the exported value for the module.”
UI5模块的加载器:ui5loader.js
![](https://user-images.githubusercontent.com/5669954/59995885-498b5780-968b-11e9-82c1-e1fc455d655a.png)
那么我们应用代码的controller里到底return什么值呢?即BaseController调用extend方法后的返回值。
![](https://user-images.githubusercontent.com/5669954/59995886-498b5780-968b-11e9-85eb-2f247dfc5d14.png)
这个返回值在BaseController的基础上,包含了我们应用程序自定义的onInit方法。
![](https://user-images.githubusercontent.com/5669954/59995887-4a23ee00-968b-11e9-87cf-702166a94f6e.png)
至此,App.controller.js这个模块就加载完成了。
执行ready之前:
![](https://user-images.githubusercontent.com/5669954/59995888-4a23ee00-968b-11e9-8147-abf317044ba2.png)
ready函数的职责就是把模块实例的state设置成Ready,settled设置成true:
![](https://user-images.githubusercontent.com/5669954/59995889-4a23ee00-968b-11e9-8fe8-236d5ccbd277.png)
![](https://user-images.githubusercontent.com/5669954/61616089-2a87e180-ac9a-11e9-861d-c29c2cf897af.png)
相关文章
- SAP UI5 应用开发教程之七十一 - SAP UI5 页面的嵌套路由试读版
- SAP UI5 初学者教程之二十五 - 使用代理服务器解决 SAP UI5 应用访问远端 OData 服务的跨域问题试读版
- SAP UI5 neo-app.json
- 如何禁掉SAP Fiori上传文件的病毒扫描设置
- SAP CRM WebClient UI注释引起的错误消息:Uncaught SyntaxError - unexpected end of input
- 如何在SAP社区上查找其他SAP从业者遇到的问题或者提新问题
- 关于 SAP Spartacus Shell App 客户应用的调试
- SAP Spartacus module 延迟加载和正常加载的 chunk 内容差异
- SAP Spartacus 定义在app.module.ts里的providers依赖注入元数据何时得到处理
- 如何在SAP Spartacus里捕捉感兴趣的事件
- SAP Spartacus初始化时和user token相关的APP INITIALIZER
- SAP Spartacus app module注入config module的过程
- 如何用SAP Cloud for Customer的手机App创建销售订单
- 如何用SAP Cloud for Customer的手机App创建销售订单
- SAP电商云简介
- SAP HANA数据库里对中文字符串排序的实现
- 使用jconsole监测SAP commerce运行时
- SAP WebIDE 里的 neo-app.json 文件用途
- SAP云平台CloudFoundry上部署了一个应用的技术明细
- SAP Authenticator Android app
- SAP Netweaver的负载均衡消息服务器 vs CloudFoundry的App Router
- 如何处理SAP Fiori Launchpad错误消息:Could not start the app due to a configuration problem
- SAP Fiori issue排查:why search by ID does not work
- Service Broker in SAP Gateway and Kubernetes
- 关于 SAP Spartacus Shell App 客户应用的调试