1.manifest.json中配置路由跳转信息
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",//路由初始化的类
"viewType": "XML",//类型
"viewPath": "crudTrainingDemo.view",//页面要在哪里执行,项目名.view
"controlId": "app",//容器ID
"controlAggregation": "pages",//分页
"transition": "slide",//切换效果
"bypassed": {
"target": "notFound"//没有数据进入的target
},
"viewLevel": 1
},
"routes": [{
"name": "table",//路由跳转时需要指定的名字view
"pattern": "",
"greedy": false,
"target": "table"
}, {
"name": "detail",
"pattern": "detail/{oId}",//url后面的
"greedy": false,
"target": "detail"
}, {
"name": "update",
"pattern": "update/{oId}",
"greedy": false,
"target": "update"
}, {
"name": "create",
"pattern": "create",
"greedy": false,
"target": "create"
}],
"targets": {
"table": {
"viewType": "XML",
"transition": "slide",
"clearAggregation": true,
"viewName": "Table",//要和view名匹配上
"viewId": "table",
"viewLevel": 1
},
"detail": {
"viewType": "XML",
"transition": "slide",
"clearAggregation": true,
"viewName": "Detail",
"viewId": "detail",
"viewLevel": 2
},
"update": {
"viewType": "XML",
"transition": "slide",
"clearAggregation": true,
"viewName": "Update",
"viewId": "update",
"viewLevel": 2
},
"notFound": {
"viewType": "XML",
"transition": "show",
"clearAggregation": true,
"viewName": "NotFound",
"viewId": "notFound"
},
"create": {
"viewType": "XML",
"transition": "slide",
"clearAggregation": true,
"viewName": "Create",
"viewId": "create",
"viewLevel": 2
}
}
}
2. Component.js文件初始化路由
3.在各Controller中实例化路由并使用
封装getRouter方法
按钮操作后触发事件
4.返回上一页面
定义"sap/ui/core/routing/History"
5.路由监听
1.在Controller中监听路由跳转(跳转之后我们到下一个页面可以监听上一个页面传来的一些参数)
2.读取路由参数
以上