我已经在SAPUI5中完成了一个应用程序&部署在FLP中。第一次加载需要超过一分钟的,之后只需2到3秒。
当我在Chrome控制台中运行性能时,它显示脚本需要花费太多的时间。如何减少应用程序的初始加载时间?
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"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Orders</title>
<script id="sap-ui-bootstrap"
src="/sap/public/bc/ui5_ui5/1/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m, sap.ui.core"
data-sap-ui-theme="sap_belize"
data-sap-ui-bindingSyntax="complex"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"
data-sap-ui-resourceroots='{"orders": "."}'
></script>
<script>
sap.ui.getCore().attachInit(function () {
sap.ui.require([
"sap/m/Shell",
"sap/ui/core/ComponentContainer"
], function (Shell, ComponentContainer) {
new Shell({
app: new ComponentContainer({
height : "100%",
name : "orders"
})
}).placeAt("content");
});
});
</script>
</head>
<body class="sapUiBody" id="content">
</body>
</html>控制器模块
sap.ui.define([
"./BaseController",
"sap/ui/model/json/JSONModel",
"sap/ui/core/routing/History",
"../model/formatter",
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator",
"sap/m/MessageToast"
], function(BaseController, JSONModel, /* ... */) { /*... */ }));XML命名空间
<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:semantic="sap.m.semantic"
xmlns:core="sap.ui.core"
xmlns:table="sap.ui.table"
xmlns:smartTable="sap.ui.comp.smarttable"
xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
controllerName="orders.controller.Worklist"
>
<!-- ... -->
</mvc:View>发布于 2018-05-13 17:43:13
组件预加载文件有助于在初始加载中提高应用程序的性能。例如,您可以通过SAP轻松地创建这个文件:右键单击项目→Build→Build project来创建/更新预加载文件。
发布于 2018-05-11 12:41:04
虽然一分钟时间太长,但是UI5应用程序在第一次运行它时加载时间更长是正常的,因为它从UI5服务器下载UI5库--在下载库之后,它们被缓存到浏览器中,因此在下一次运行时会更快。
https://stackoverflow.com/questions/50292032
复制相似问题