SAPUI5-路由Router使用

1.manifest.json中配置路由跳轉(zhuǎn)信息

"routing": {

"config": {

"routerClass": "sap.m.routing.Router",//路由初始化的類

"viewType": "XML",//類型

"viewPath": "crudTrainingDemo.view",//頁面要在哪里執(zhí)行,項目名.view

"controlId": "app",//容器ID

"controlAggregation": "pages",//分頁

"transition": "slide",//切換效果

"bypassed": {

"target": "notFound"http://沒有數(shù)據(jù)進(jìn)入的target

},

"viewLevel": 1

},

"routes": [{

"name": "table",//路由跳轉(zhuǎn)時需要指定的名字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方法

按鈕操作后觸發(fā)事件


4.返回上一頁面

定義"sap/ui/core/routing/History"

5.路由監(jiān)聽


1.在Controller中監(jiān)聽路由跳轉(zhuǎn)(跳轉(zhuǎn)之后我們到下一個頁面可以監(jiān)聽上一個頁面?zhèn)鱽淼囊恍﹨?shù))

2.讀取路由參數(shù)

以上


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容