假设我们有一条路线和一个目标:
"routes": [{
"pattern": "modify",
"name": "modify",
"target": [
"master",
"modify"
]
}],
"targets": {
"modify": {
"viewName": "Modify",
"viewId": "modify",
"viewLevel": 2
}
}
所以我可以通过以下方式访问路线this.getRouter().navTo("modify")
,同时我可以通过以下方式访问目标this.getRouter().getTargets().display("modify")
。两个 API 都可以通过第二个参数携带参数。似乎也达到了同样的效果。
我可以访问目标而无需为其定义路由。所以我不太明白为什么我需要一条路线?
Ref: sap.m.路由.目标 https://sapui5.hana.ondemand.com/#/api/sap.m.routing.Targets and
sap.ui.core.routing.Router https://sapui5.hana.ondemand.com/#/api/sap.ui.core.routing.Router
display https://github.com/SAP/openui5/blob/rel-1.48.5/src/sap.ui.core/src/sap/ui/core/routing/async/Target.js#L39与以下相比,在不更改哈希值的情况下显示目标视图navTo https://github.com/SAP/openui5/blob/rel-1.48.5/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L522.
您可以在教程中找到更多信息“显示目标而不更改哈希值 https://openui5nightly.hana.ondemand.com/#/topic/d9efab307ecc42b180b12cc8956e22d7".
两个 API 都可以通过第二个参数携带参数。似乎也达到了同样的效果。
- The data in
display
method是为了display
event处理程序。当事件发生时fired https://github.com/SAP/openui5/blob/rel-1.48.5/src/sap.ui.core/src/sap/ui/core/routing/async/Target.js#L169,处理程序携带我们之前传递的数据。
- The 参数图我们可以传递给
navTo
is 强制如果该模式实际上等待一个参数,例如如果我们最初定义了这样的模式:"pattern": "modify/{id}"
。查看 ”导航至具有强制参数的路线 https://openui5nightly.hana.ondemand.com/#/topic/f96d2522a5ca4382a274ae3c6d002ca0".
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)