Sapui5 未捕获类型错误:this.getRouter不是函数
尝试将Sapui5 未捕获类型错误:this.getRouter不是函数,sapui5,sap-fiori,Sapui5,Sap Fiori,尝试将对象路由添加到主路由(表页),但返回this.getRouter不是函数错误 在主控制器中: onPress : function(oEvent) { this._showObject(oEvent.getSource()); }, _showObject : function (oItem) { this.getRouter().navTo("object", { objectId: oItem.getBi
对象
路由添加到主路由(表页),但返回this.getRouter不是函数
错误
在主控制器中:
onPress : function(oEvent) {
this._showObject(oEvent.getSource());
},
_showObject : function (oItem) {
this.getRouter().navTo("object", {
objectId: oItem.getBindingContext().getProperty("task_id")
});
},
在Component.js中(我已经检查过了,它已经加载了,没有产生错误)
))
_showObject中的此值:
f{meventergistry:Object,oView:f}
如何修复此错误
onPress : function(oEvent) {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo("object", {
objectId:
oEvent.getSource().getBindingContext().getProperty("task_id")
});
它正在工作
参考:
感谢@hdereli 我忘了包含帮助程序:
BaseController.js
getRouter:函数(){
返回sap.ui.core.UIComponent.getRouterFor(this)
},
试试看
return this.getOwnerComponent().getRouter();
您可以定义一个BaseController类,并使用它来定义其他控制器。SAPUI5示例具有此基本控制器。其中定义了getRouter方法。你错过了那部分。
return this.getOwnerComponent().getRouter();