我们已经将sapui5应用程序从1.44升级到1.56。我的应用程序在1.44版本中正常工作。
升级后,它给了我下面的错误。
“未捕获(承诺)错误:找不到指定的组件控制器'com.test.ui.Component'!”
注意:Component.js成功加载即无404错误Component.js
<script id="sap-ui-bootstrap"
src="../../../resources/sap-ui-core.js"
data-sap-ui-libs="sap.m, sap.me"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-compatVersion="1.16"
data-sap-ui-appCacheBuster="./"
data-sap-ui-resourceroots='{"com.test.ui": "./"}'></script>
<link rel="stylesheet" type="text/css" href="CSS/style.css" />
<script>
sap.ui.getCore().attachInitEvent(function() {
var oShell = new sap.m.Shell("idshell");
var oComponentContainer = new sap.ui.core.ComponentContainer({
height : "100%",
name : "com.test.ui"
});
oShell.setApp(oComponentContainer);
oShell.placeAt("content");
});
</script>
Component.js
jQuery.sap.declare("com.test.ui.Component");
jQuery.sap.require("sap.m.routing.RouteMatchedHandler");
sap.ui.define(["sap/ui/core/UIComponent"],function(UIComponent){
"use strict";
UIComponent.extend(
"com.test.ui.Component", {
metadata: {
"name": "com.test.ui",
"version": "1.0",
"includes": ["css/style.css"],
"dependencies": {
"libs": ["sap.m", "sap.ui.core", "sap.me",
"sap.ushell"
],
"components": []
},
"config": {
"resourceBundle": "i18n/messageBundle.properties",
"titleResource": "title",
"serviceConfig": {
"url": "/sap/opu/odata/.."
}
},
"routing": {
"config": {
"viewType": "XML",
"viewPath": "com.test.ui.view",
"clearTarget": false
},
"routes": [{
name: "route1",
view: "Desktop",
pattern: ":all*:",
targetControl: "rootapp",
targetAggregation: "pages"
}]
}
},
/**
* First method of the component to be called. It initializes the odata and the i18n models, calls the super constructor
* and initializes the router.
* @memberOf com.test.ui.Component
*/
init: function() {
// Fetch the rootpath of the component
var rootPath = jQuery.sap.getModulePath("com.test.ui");
//Create the i18n model with the properties file and set for the component with the name 'i18n'
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl: rootPath + "/i18n/messageBundle.properties"
});
this.setModel(i18nModel, "i18n");
//Fetch the odata service url and create an odata model and set it for the component with the name 'odata'
var sServiceUrl = this.getMetadata().getConfig().serviceConfig.url;
var oModel = new sap.ui.model.odata.ODataModel(
sServiceUrl);
this.setModel(oModel, "odata");
var sServiceUrl1 = "/sap/opu/odata/...";
var oModel = new sap.ui.model.odata.ODataModel(
sServiceUrl1);
this.setModel(oModel, "odata1");
//call the super-constructor
sap.ui.core.UIComponent.prototype.init.apply(this,
arguments);
// Initialize route matched handler and router
this.oRouteMatchedHandler = new sap.m.routing.RouteMatchedHandler(
this.getRouter());
this.getRouter().initialize();
},
createContent: function() {
return sap.ui.view({
viewName: "com.test.ui.view.View1",
type: "XML",
viewData: {
component: this
}
});
}
});
});
任何帮助将不胜感激。
项目结构