gpt4 book ai didi

javascript - SAPUI5 路由 : Cannot read property 'initialize' of undefined

转载 作者:行者123 更新时间:2023-11-29 17:57:36 29 4
gpt4 key购买 nike

我在创建路由器时遇到了问题。我每次都会收到错误 Cannot read property 'initialize' of undefined

这是我在 Component.js 中的代码:

sap.ui.define([ "sap/ui/core/UIComponent", "sap/ui/model/json/JSONModel",
"sap/ui/core/routing/History", "sap/m/routing/RouteMatchedHandler" ],
function(UIComponent, JSONModel, Router, RouteHandler) {
"use strict";
return UIComponent.extend("myApp.Component", {
metadata: {
routing:{
config: {
viewType:"XML",
viewPath:"myApp.view",
targetControl: "idRoot",
targetAggregation: "pages",
clearTarget: false
},
routes:[{
pattern: "",
name:"Master",
view:"Master"
}]
}
},

init: function(){
var router = this.getRouter(); //Doesn't work
router.initialize(); //ERROR HERE
},

如果我尝试 var router = sap.ui.core.routing.Router.getRouter(); 是一样的。

谁能帮我解决这个问题?

最佳答案

您缺少这行代码:

UIComponent.prototype.init.apply(this, arguments);

在初始化路由器之前需要先调用父级的init函数。

关于javascript - SAPUI5 路由 : Cannot read property 'initialize' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37719189/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com