Javascript 我在SAP WebIDE中遇到了在UI5应用程序上显示XS OData服务的问题
我正在创建一个应用程序以向用户显示应用程序的推荐结果,但无法在应用程序上显示该结果 错误显示 显示基本控制器文件中未定义的属性 错误代码为getOwnerComponent(“myComp”)。getTargets()。显示(到)在appview.controller.js文件(控制器文件)中 注意:如果我对组件容器使用方法1,我可以初始化路由器,但错误目标未定义,因为找不到组件id。 但是,如果我对组件容器使用方法2,我可以获取OwnerComponent,但显示undefined,因为我无法初始化路由器 有什么想法吗 appview.controller.jsJavascript 我在SAP WebIDE中遇到了在UI5应用程序上显示XS OData服务的问题,javascript,sapui5,hana,sap-web-ide,Javascript,Sapui5,Hana,Sap Web Ide,我正在创建一个应用程序以向用户显示应用程序的推荐结果,但无法在应用程序上显示该结果 错误显示 显示基本控制器文件中未定义的属性 错误代码为getOwnerComponent(“myComp”)。getTargets()。显示(到)在appview.controller.js文件(控制器文件)中 注意:如果我对组件容器使用方法1,我可以初始化路由器,但错误目标未定义,因为找不到组件id。 但是,如果我对组件容器使用方法2,我可以获取OwnerComponent,但显示undefined,因为我无法
handlePressOpenMenu: function(oEvent) {
var oButton = oEvent.getSource();
// create menu only once
if (!this._menu) {
this._menu = sap.ui.xmlfragment("apps.html.fragment.view_menu", this);
this.getView().addDependent(this._menu);
}
var eDock = sap.ui.core.Popup.Dock;
this._menu.open(this._bKeyboard, oButton, eDock.BeginTop, eDock.BeginBottom, oButton);
},
handleMenuItemPress: function(oEvent) {
if (oEvent.getParameter("item").getSubmenu()) {
return;
}
var to = oEvent.getParameter("item").data("to");
if (to) {
this.getOwnerComponent("myComp").getTargets().display(to);
}
},
manifest.json
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"async": true,
"viewPath": "apps.html",
"controlAggregation": "pages",
"controlId": "idAppControl",
"transition": "slide"
},
"routes": [{
"name": "appview",
"pattern": "",
"target": ["appview"]
}],
"targets": {
"appview": {
"clearAggregation": true,
"viewName": "appview"
},
"xsodata.collaborative": {
"clearAggregation": true,
"viewName": "xsodata.collaborative"
},
"xsodata.contentbased": {
"clearAggregation": true,
"viewName": "xsodata.contentbased"
},
"xsjs.apl_recommendation": {
"clearAggregation": true,
"viewName": "xsjs.apl_recommendation"
},
"xsjs.pal_apriori": {
"clearAggregation": true,
"viewName": "xsjs.pal_apriori"
}
}
}
}
}
}
component.js
return UIComponent.extend("apps.html.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
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
// set the device model
this.setModel(models.createDeviceModel(), "device");
// initialise router
this.getRouter().initialise();
}
});
});
index.html方法1
sap.ui.getCore().attachInit(function() {
new sap.m.Shell({
app: new sap.ui.core.ComponentContainer({
id:"myComp",
height : "100%",
name : "movielens.html",
propagateModel:true
}).placeAt("content")
});
索引html方法2
sap.ui.getCore().attachInit(function() {
var oComp = sap.ui.getCore().createComponent({
name:"apps.html",
id:"myComp",
height:"100%",
propagateModel:true
});
new sap.m.Shell({
app: new sap.ui.core.ComponentContainer({
component:oComp
}).placeAt("content")
});
执行结果应该是基于用户选择的推荐显示