我需要知道 - 没有组件的哈希转换器和路由器概念.js因为我无法在 SAPUI5 SDK - 开发人员指南中找到。
有人可以提供一个简单的示例,其中可以通过更改哈希导航到另一个页面吗?
~拉胡尔
在 SAPUI 演练教程中对路由概念进行了很好的解释:https://sapui5.hana.ondemand.com/sdk/#docs/guide/e5200ee755f344c8aef8efcbab3308fb.html
一个很好且简单的例子可以在 UI5 探索的应用程序中找到:https://sapui5.hana.ondemand.com/explored.html#/entity/sap.ui.core.routing.Router/samples
要在单独的页面中启动示例以查看浏览器中的哈希部分,您可以使用以下链接:https://sapui5.hana.ondemand.com/test-resources/sap/ui/core/demokit/sample/RoutingFullscreen/RoutingFullscreen.html
您是否尝试过链接文档中给出的示例?我复制并扩展了一点:
var router = new Router(
// Routes
[
{
// no view creation related properties are in the route
name: "startRoute",
//no hash
pattern: "",
// you can find this target in the targetConfig
target: "welcome"
},
{
// no view creation related properties are in the route
name: "productRoute",
//no hash
pattern: "product/{productId}",
// you can find this target in the targetConfig
target: "productTarget"
}
],
// Default values shared by routes and Targets
{
viewNamespace: "my.application.namespace",
viewType: "XML"
},
// You should only use this constructor when you are not using a router with a component.
// Please use the metadata of a component to define your routes and targets.
// The documentation can be found here: sap.ui.core.UIComponent#.extend.
null,
// Target config
{
//same name as in the route called 'startRoute'
welcome: {
// All properties for creating and placing a view go here or in the config
viewName: "Welcome",
controlId: "app",
controlAggregation: "pages"
},
productTarget: {
// All properties for creating and placing a view go here or in the config
viewName: "Product",
controlId: "app",
controlAggregation: "pages"
}
});
// You can navigate to a route programmatically too.
// This is the same as entering the url ...index.html#product/P12345 in your browser window.
router.navTo("productRoute",{productId: "P12345"});