我在我的项目中使用i18n文件。我需要加粗属性“missingItems”的占位符中的文本。这是i18n的财产:
missingItems = The items: {0} are missing!
控制器:
var missingItemsArray= ["item1", "item2", "item3"]
var sMessage = this.getView().getModel("i18n").getResourceBundle().getText("missingItems", [missingItemsArray]);
MessageBox.show(sMessage, {
icon: MessageBox.Icon.WARNING,
title: "exampleTitle",
actions: [sap.m.MessageBox.Action.OK],
id: "messageBoxId2",
defaultAction: sap.m.MessageBox.Action.OK,
details: "exampleDetails"
});
任何帮助将受到高度赞赏! :)
答案 0 :(得分:1)
您应该使用 FormattedText 这样的组件:
的I18n
missingItems = The items: <strong>{0}</strong> are missing!
控制器
var missingItemsArray= ["item1", "item2", "item3"];
var sMessage = this.getView().getModel("i18n").getResourceBundle().getText("missingItems", [missingItemsArray]);
var formattedText = new sap.m.FormattedText("FormattedText", {
htmlText: sMessage
});
MessageBox.show(formattedText, {
icon: MessageBox.Icon.WARNING,
title: "exampleTitle",
actions: [sap.m.MessageBox.Action.OK],
id: "messageBoxId2",
defaultAction: sap.m.MessageBox.Action.OK,
details: "exampleDetails"
});
示例:https://sapui5.hana.ondemand.com/#/sample/sap.m.sample.FormattedText/code/C.controller.js
答案 1 :(得分:0)
font-weight: bold
将其添加为粗体占位符文本