没有Component.js的导航?

时间:2016-06-07 11:59:31

标签: hash routing navigation sapui5

我需要知道 - HashChangerRouter没有Component.js的概念,因为我无法在SAPUI5 SDK - Developers Guide中找到。

有人可以提供一个简单的例子,通过更改哈希来导航到另一个页面吗?

〜拉胡

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

您是否尝试过已链接的文档中给出的示例? 我复制并扩展了一点:

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"});