我从头开始设置一个非常简单的应用程序,以揭开一些基础知识的神秘面纱。只是一个视图在这一刻工作,意味着组件工作(路由在manifest.json中定义,由Component.js调用)但是有一个奇怪的调试器错误(见下文)
此外,我看到Component.js正在网络选项卡中加载,但在某个时刻,我看到一个额外的尝试(在加载视图之后)来获取一个不知道它是什么的组件(见下文)
查看失败的请求,我看到了这个:
这不是我的应用程序路径,与称为“Flex服务”的东西相关,我不知道它是什么。
有没有人知道这个组件异常来自哪里?下面附带的代码看起来很简单。
提前致谢,
格雷格
的index.html
<!DOCTYPE HTML>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>Test_space</title>
<script id="sap-ui-bootstrap"
src="resources/sap-ui-core.js"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_belize"
data-sap-ui-compatVersion="edge"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-resourceroots='{"zouz.sapui5.skeleton": "../webapp/"}'>
</script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script>
sap.ui.getCore().attachInit(function() {
new sap.m.Shell({
appWidthLimited : false,
app: new sap.ui.core.ComponentContainer({
height : "100%",
name : "zouz.sapui5.skeleton"
})
}).placeAt("content");
});
</script>
</head>
<body class="sapUiBody" id="content">
</body>
Component.js
sap.ui.define([
"sap/ui/core/UIComponent"
], function(UIComponent) {
"use strict";
return UIComponent.extend("zouz.sapui5.skeleton.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);
this.getRouter().initialize();
}
});
});
App.controller.js
sap.ui.define([
"zouz/sapui5/skeleton/controller/BaseController",
"sap/ui/model/json/JSONModel"
], function (BaseController, JSONModel) {
"use strict";
return BaseController.extend("zouz.sapui5.skeleton.controller.App", {
onInit : function () {
var oViewModel,
fnSetAppNotBusy,
iOriginalBusyDelay = this.getView().getBusyIndicatorDelay();
oViewModel = new JSONModel({
busy : true,
delay : 0
});
this.setModel(oViewModel, "appView");
fnSetAppNotBusy = function() {
oViewModel.setProperty("/busy", false);
oViewModel.setProperty("/delay", iOriginalBusyDelay);
};
this.getOwnerComponent().getModel().metadataLoaded().
then(fnSetAppNotBusy);
// apply content density mode to root view
// this.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass());
},
onBeforeRendering : function() {
}
});
}
);
Main.controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("zouz.sapui5.skeleton.controller.Main", {
onInit : function () {
},
onBeforeRendering : function() {
}
});
}
);
App.view.xml
<mvc:View
xmlns:mvc="sap.ui.core.mvc"
controllerName="zouz.sapui5.skeleton.controller.App"
displayBlock="true"
xmlns="sap.m"
xmlns:core="sap.ui.core">
<App id="app"
busy="{appView>/busy}"
busyIndicatorDelay="{appView>/delay}"/>
Main.view.xml
</mvc:View>
<mvc:View controllerName="zouz.sapui5.skeleton.controller.Main"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:core="sap.ui.core"
displayBlock="true">
<App>
<pages>
<Page title="Greg test stuff">
<content id="#contentPlaceholder">
<Text text="This is view 1"/>
</content>
</Page>
</pages>
</App>
</mvc:View>
的manifest.json
{
"_version": "1.5.0",
"sap.app": {
"id": "zouz.sapui5.skeleton",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.40.12"
},
"dataSources": {
"mainService": {
"uri": "/DEV/sap/opu/odata/SAP/ZCONTRACTS_SRV/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
}
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone@2": "",
"tablet": "",
"tablet@2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": ["sap_hcb", "sap_belize"]
},
"sap.ui5": {
"rootView": {
"viewName": "zouz.sapui5.skeleton.view.App",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {},
"sap.ushell": {},
"sap.collaboration": {},
"sap.ui.comp": {},
"sap.uxap": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "zouz.sapui5.skeleton.i18n.i18n"
}
},
"": {
"dataSource": "mainService",
"preload": true,
"settings": {
"defaultBindingMode": "TwoWay"
}
}
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "zouz.sapui5.skeleton.view",
"async": true,
"controlId": "app",
"controlAggregation": "pages",
"bypassed": {
"target": []
}
},
"routes": [{
"name": "Main",
"pattern": "",
"titleTarget": "",
"greedy": false,
"target": ["Main"]
},
{
"name": "Agreement",
"pattern": "AgreementsSet/{objectId}",
"titleTarget": "",
"greedy": false,
"target": ["Agreement"]
}],
"targets": {
"Main": {
"viewType": "XML",
"transition": "slide",
"clearAggregation": "",
"viewName": "Main",
"viewId": "Main",
"viewLevel": 1
},
"Agreement": {
"viewType": "XML",
"transition": "slide",
"clearAggregation": true,
"viewName": "Agreement",
"viewLevel": 2,
"viewId": "Agreement"
}
}
}
}
}
您可以忽略这些错误。这两个失败都与“Flexibility services”有关。它们基本上检查用户是否对组件(app)进行了任何个性化修改。