通过 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' /><scriptsrc="resources/sap-ui-core.js" id="sap-ui-bootstrap"data-sap-ui-libs="sap.m"> </script><script>// Set the log level to INFOjQuery.sap.log.setLevel(jQuery.sap.log.Level.INFO);// Get reference the Core objectvar oCore = sap.ui.getCore();// Read Corevar 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 Corevar 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 () 語句。
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' /><scriptsrc="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 INFOjQuery.sap.log.setLevel(jQuery.sap.log.Level.INFO);// Get reference the Core objectvar oCore = sap.ui.getCore();// Read Corevar 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 Corevar 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 () 語句。
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的通过 url 参数 parameters 和 script tag 属性来配置 SAP UI5 运行时的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 天猫精灵 IN 糖 3 Pro 智能音箱
- 下一篇: SAP UI5 应用开发教程之六 - 了