未捕获的类型错误:无法读取属性'oTargetControl'的未定义
Uncaught TypeError: Cannot read property 'oTargetControl' of undefined
加载应用程序时,我收到以下错误:
未捕获的类型错误:无法读取未定义的""的属性"oTargetControl"
我正在使用路由配置(这是SAPui5应用程序)。
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "myNav.view",
"controlId": "app",
"controlAggregation": "pages"
},
"routes": [{
"pattern": "",
"name": "first",
"target": "first"
}, {
"pattern": "",
"name": "second",
"target": "second"
}],
"targets": {
"first": {
"viewName": "First"
},
"second": {
"viewName": "Second"
}
}
}
我的Component.js代码是
UIComponent.prototype.init.apply(this, arguments);
this.setModel(models.createDeviceModel(), "device");
this.getRouter().initialize();
这是一个简单的导航示例,我有两个视图(第一视图和第二视图)。
我该如何解决这个问题?
您指定了根视图吗?
您为路由指定了controlId"app"和controlAggregation"pages"。这意味着您的路由器将搜索id为"app"的控件,并尝试用匹配的路由替换此控件的聚合"pages"。
我猜oTargetControl
是未找到的控件"应用程序",这就是出现错误的原因。
Sth。这样应该在你的应用程序配置中:
"rootView": "my.app.Root"
其次,正如纳比已经提到的路由工作严格的第一场比赛,第一次发球,这意味着你的观点第二永远不会被使用。您要么必须调整模式,要么使用贪婪标志。
参见https://sapui5.hana.ondemand.com/sdk/#docs/guide/cf3c57c89ef0491793d1ce327ab4f9b2.html
您的两条路由具有相同的模式。在哈希为空(pattern=")的情况下,您希望匹配哪些路由?我想这就是问题的原因。请确保您有不同的模式,或者使用底层库crossroads.js 支持的贪婪功能
在我的例子中,我在路由中添加了"async":true属性
`
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "sap.sapx5Exercise03_1.view",
"controlId": "menu",
"targetControl" : "app",
"transition": "slide",
"controlAggregation": "pages",
"bypassed": {
"target": "notFound"
},
"async" : true
},
`。。。。。。记住"controlId":"menu",属性的值应该在您的视图中
`
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="sap.sapx5Exercise03_1.controller.Menu"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
>
<App id="menu">
`。。。。。。
相关文章:
- 主干中的模型属性未定义
- JavaScript 2d 数组导致“无法读取未定义的属性'未定义'”
- JSON对象属性未定义
- Waypoint的循环,退出循环后属性未定义
- Javascript:错误“无法设置属性”..'未定义”
- 翡翠 - 显示对象属性 - 未定义
- 属性未定义,但控制台.log可以看到它
- JavaScript 对象的属性未定义
- Javascript 对象属性未定义(但属性已设置)
- DOM 元素属性未定义 - jquery / ruby on rails.
- Nodejs JSON 属性未定义
- 错误:窗口打开器的属性未定义
- angular Js:Array.lenght属性未定义
- 正在尝试访问JavaScript对象的属性=未定义
- Marionette属性未定义,请从API获取
- AngularJS作用域属性未定义
- 对象的属性未定义,尽管已指定值
- 为什么我一直收到一个错误,说对象属性未定义
- 对象属性未定义,但我看到它不是
- .map()img src属性未定义