SAP UI5 Index Title 通过 i18n 来显示
1. SAP UI5 Index Title 使用i18n 来动态控制
——————————————–
关于的SAPUI5 这一需求的实现,我们需要了解SAPUI5 启动运行时的加载顺序。
SAPUI5 程序启动 -> Index.html -> Component.js -> (XML/JS/html/xhtml)/ View -> Controller
在Index.html 装载时,SAPUI5 内并未装载完成,所以我需要将I18n 的操作放在Components.js 中。
在Component.js 中调用i18n 的内容操作如下:
sap.ui.define([
“sap/ui/core/UIComponent”,
“sap/ui/Device”,
“osr/sap/sd/clur/model/models”
], function(UIComponent, Device, models) {
“use strict”;
return UIComponent.extend(“osr.sap.sd.clur.Component”, {
metadata: {
manifest: “json”
},
/**
* The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
* @public
* @override
*/
init: function() {
// call the base component’s init function
UIComponent.prototype.init.apply(this, arguments);
// set the device model
this.setModel(models.createDeviceModel(), “device”);
},
onAfterRendering: function() {
document.title = this.getModel(“i18n”).getResourceBundle().getText(“title”);
}
//<—End
});
});