1. 程式人生 > 其它 >關於 SAP Fiori Elements 應用標題屬性(title) 的複製邏輯單步除錯

關於 SAP Fiori Elements 應用標題屬性(title) 的複製邏輯單步除錯

為支援國際化(internationalization),title 屬性的值沒有硬編碼,而是維護在 i18n_<language_code>.properties 裡:

https://ldai7er9.wdf.sap.corp:44300/sap/bc/ui5_ui5/sap/jerryfioriapp/i18n/i18n_zh.properties

https://ldcigm4.wdf.sap.corp:44355/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html?sap-ui-language=ZH&sap-client=001#Opportunity-manageOpportunity&/detail/Opportunities(guid'FA163EE5-6C3A-1ED7-B883-0ED9A99A201F')

想要以中文環境載入 SAP UI5 應用,在 url 後面加上引數即可:

sap-ui-language=ZH

維護在 i18n_<language_code>.properties 裡的標題內容,為漢字的 unicode:

HTML header 對應的設定:meta content="text/html;charset=UTF-8":

SAP Fiori Elements 應用 index.html 裡 title 屬性的值:

<title>{{appTitle}}</title>

使用下列這行 JavaScript 程式碼,可以在 window.document title 屬性被修改時,讓斷點自動觸發:

Object.defineProperty(window.document, "title", { set: function(){ debugger;}});

從下圖可見,Fiori Elements 應用的 title 屬性,其值來自於 oMetadata.title:

再研究 metadata 是從哪裡解析的:

AppConfiguration.js:

答案是來自 manifest.json:

更多Jerry的原創文章,盡在:"汪子熙":