没有 Component.js 的导航?
Navigation without Component.js?
我需要知道 - HashChanger and Router concept without Component.js as I am not able to find in SAPUI5 SDK - Developers Guide.
谁能提供一个简单的例子,可以通过更改哈希导航到另一个页面?
~拉胡尔
路由概念在 SAPUI 演练教程中有很好的解释:https://sapui5.hana.ondemand.com/sdk/#docs/guide/e5200ee755f344c8aef8efcbab3308fb.html
可以在 UI5 explored app 中找到一个很好的简单示例:
https://sapui5.hana.ondemand.com/explored.html#/entity/sap.ui.core.routing.Router/samples
要在单独的页面中启动示例以在浏览器中查看哈希部分,您可以使用此 link:
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"});
我需要知道 - HashChanger and Router concept without Component.js as I am not able to find in SAPUI5 SDK - Developers Guide.
谁能提供一个简单的例子,可以通过更改哈希导航到另一个页面?
~拉胡尔
路由概念在 SAPUI 演练教程中有很好的解释:https://sapui5.hana.ondemand.com/sdk/#docs/guide/e5200ee755f344c8aef8efcbab3308fb.html
可以在 UI5 explored app 中找到一个很好的简单示例: https://sapui5.hana.ondemand.com/explored.html#/entity/sap.ui.core.routing.Router/samples
要在单独的页面中启动示例以在浏览器中查看哈希部分,您可以使用此 link: 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"});