通过 url 参数 parameters 和 script tag 属性来配置 SAP UI5 运行时

简介: 通过 url 参数 parameters 和 script tag 属性来配置 SAP UI5 运行时

Configuration of the SAPUI5 Runtime using URL parameters


新建一个 SAP UI5 应用,index.html 实现如下图所示:


<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8' />
<script
  src="resources/sap-ui-core.js" 
  id="sap-ui-bootstrap"
  data-sap-ui-libs="sap.m"> 
</script>
<script>
  // Set the log level to INFO
  jQuery.sap.log.setLevel(jQuery.sap.log.Level.INFO);
  // Get reference the Core object
  var oCore = sap.ui.getCore();
  // Read Core
  var oLibMap = oCore.getLoadedLibraries();
  for (key in oLibMap) {
    jQuery.sap.log.info("Loaded Library name", key);
  }
  jQuery.sap.log.info("Has model?", oCore.hasModel().toString());
  jQuery.sap.log.info("Is mobile?", oCore.isMobile().toString());
  // Read Configuration object from the Core
  var oConfig = oCore.getConfiguration();
  jQuery.sap.log.info("Accessibility", oConfig.getAccessibility().toString());
  jQuery.sap.log.info("Debug", oConfig.getDebug().toString());
  jQuery.sap.log.info("Language", oConfig.getLanguage());
  jQuery.sap.log.info("Locale", oConfig.getLocale());
  jQuery.sap.log.info("Version of SAPUI5 Framework", oConfig.getVersion());
  jQuery.sap.log.info("Theme", oConfig.getTheme());
  jQuery.sap.log.info("User agent", navigator.userAgent);
  // Reset the log level to default of ERROR 
  jQuery.sap.log.setLevel(jQuery.sap.log.Level.ERROR);
</script>
</head>
<body class="sapUiBody" role="application">
  <div id="content"></div>
</body>
</html>

使用如下的 url 进行测试:


http://localhost:8080/sapui5.configurl.demo?sap-ui-accessibility=false&sap-ui-debug=false&sap-ui-language=de&sap-ui-theme=sap_bluecrystal&data-sap-ui-xx-fakeOS=ios


请根据您的服务器配置使用端口号。 加载 index.html 将在开发者工具控制台中打印日志。 该 URL 包含多个配置参数(格式为 sap-ui-PARAMETER-NAME = ”value”),由第二个脚本区域中的代码读取。 日志级别从默认的 ERROR 更改为 INFO 并返回以打印 jQuery.sap.log.info () 语句。


image.png


Configuration of the SAPUI5 Runtime using script tag attributes

index.html:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8' />
<script
  src="resources/sap-ui-core.js" 
  id="sap-ui-bootstrap"
  data-sap-ui-libs="sap.m" 
  data-sap-ui-accessibility="false"
  data-sap-ui-debug="false"
  data-sap-ui-language="de"
  data-sap-ui-theme="sap_bluecrystal" 
  data-sap-ui-xx-fakeOS="ios">  
</script>
<script>
  // Set the log level to INFO
  jQuery.sap.log.setLevel(jQuery.sap.log.Level.INFO);
  // Get reference the Core object
  var oCore = sap.ui.getCore();
  // Read Core
  var oLibMap = oCore.getLoadedLibraries();
  for (key in oLibMap) {
    jQuery.sap.log.info("Loaded Library name", key);
  }
  jQuery.sap.log.info("Has model?", oCore.hasModel().toString());
  jQuery.sap.log.info("Is mobile?", oCore.isMobile().toString());
  // Read Configuration object from the Core
  var oConfig = oCore.getConfiguration();
  jQuery.sap.log.info("Accessibility", oConfig.getAccessibility().toString());
  jQuery.sap.log.info("Debug", oConfig.getDebug().toString());
  jQuery.sap.log.info("Language", oConfig.getLanguage());
  jQuery.sap.log.info("Locale", oConfig.getLocale());
  jQuery.sap.log.info("Version of SAPUI5 Framework", oConfig.getVersion());
  jQuery.sap.log.info("Theme", oConfig.getTheme());
  jQuery.sap.log.info("User agent", navigator.userAgent);
  // Reset the log level to default of ERROR 
  jQuery.sap.log.setLevel(jQuery.sap.log.Level.ERROR);
</script>
</head>
<body class="sapUiBody" role="application">
  <div id="content"></div>
</body>
</html>

在浏览器中打开如下网址 http://localhost:8080/sapui5.config.demo/

请根据您的服务器配置使用端口号。 加载 index.html 将在开发者工具控制台中打印日志。 第一个脚本区域(也称为 Bootstrap)中的代码包含多个配置参数(格式为 data-sap-ui-PARAMETER-NAME = ”value”),由第二个脚本区域中的代码读取。 日志级别从默认的 ERROR 更改为 INFO 并返回以打印 jQuery.sap.log.info () 语句。



相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
1月前
|
前端开发 搜索推荐 开发者
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
27 0
|
1月前
|
JavaScript 前端开发 开发者
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
15 0
|
1月前
|
XML 存储 数据格式
SAP UI5 控件 customData 属性的应用介绍
SAP UI5 控件 customData 属性的应用介绍
33 0
|
6月前
|
编解码 前端开发 API
SAP UI5 里响应式表格的 minScreenWidth 属性讲解
SAP UI5 里响应式表格的 minScreenWidth 属性讲解
27 0
SAP UI5 里响应式表格的 minScreenWidth 属性讲解
|
1月前
|
算法 开发者
【Qt UI相关】Qt5和Qt6中关于高DPI缩放属性
【Qt UI相关】Qt5和Qt6中关于高DPI缩放属性
29 1
|
1月前
|
开发者 UED
关于 SAP UI5 sap.m.Column 的 demandPopin 属性
关于 SAP UI5 sap.m.Column 的 demandPopin 属性
15 0
|
1月前
|
存储 搜索推荐 BI
sap.ui.comp.filterbar.FilterBar 的 persistencyKey 属性的作用介绍
sap.ui.comp.filterbar.FilterBar 的 persistencyKey 属性的作用介绍
10 0
|
6月前
|
存储 JavaScript 前端开发
SAP UI5 OData 请求 url 中的参数 sap-value-list=none
SAP UI5 OData 请求 url 中的参数 sap-value-list=none
31 0
|
6月前
|
JavaScript 容器
SAP UI5 控件聚合属性 Aggregation 的概念和具体使用案例
SAP UI5 控件聚合属性 Aggregation 的概念和具体使用案例
35 1
|
6月前
|
安全 网络安全
SAP CRM WebClient UI 支持的一些 url 参数
SAP CRM WebClient UI 支持的一些 url 参数
70 0

热门文章

最新文章