我正在设计一个SAP UI5应用程序,它有2个XML和1个HTML视图。我想在点击按钮时从XML视图导航到HTML视图。我该如何为此设置路由。
以下代码无效:
routing: {
config: {
routerClass: "sap.m.routing.Router",
viewType: "XML",
viewPath: "executive.WebContent.view",
controlId: "app",
controlAggregation: "pages",
},
routes: [{
"pattern": "",
"name": "View1",
"viewPath": "executive.WebContent.view",
"viewType": "XML",
"target": "View1"
},
{
"pattern": "Login",
"name": "View2",
"viewPath": "executive.WebContent.view",
"viewType": "XML",
"target": "View2"
},
{
"pattern": "Visitor",
"name": "View3",
"viewPath": "executive.WebContent.view",
"viewType": "HTML",
"target": "View3"
}
],
targets: {
"View1": {
"viewName": "Main"
},
"View2": {
"viewName": "Login"
},
"View3": {
"viewName": "Visitor"
}
}
}
请告诉我,解决方案。
答案 0 :(得分:0)
据我所知,您正在路由的配置部分定义全局类型XML;这将导致您的路线发生冲突。
我试着做你现在想做的事。但是,我找到了另一种解决方案。您可以拥有第三个XML视图,在XML中可以嵌入HTML视图。像这样的东西:
<mvc:HTMLView id="nestedViewhtmnl"
viewName="executive.WebContent.view"
controller="executive.controller.xx" type="HTML"></mvc:HTMLView>
我希望这可以帮助你=)
答案 1 :(得分:0)
您添加到 routes
的所有目标参数自 1.28 起已弃用!
根据 API 参考,routes
中的此类参数被忽略:
如果使用 target
,则忽略所有已弃用的参数。 (Source)
即不要不要在viewName
中使用viewType
、viewPath
、routes
等,但是将它们移到targets
:
{
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewPath": "executive.WebContent.view",
"viewType": "XML",
"controlId": "app",
"controlAggregation": "pages",
"async": true
},
"routes": [
{
"...": "...",
"target": "myTarget",
"viewType": "XML"
}
],
"targets": {
"myTarget": {
"viewName": "NotXML",
"viewType": "HTML",
"...": "..."
}
}
}
}