我在 SAPUI5 应用程序中为 View 声明了一个 Controller 。现在我要 View 离开时执行任务 由用户。
已经有可能向 attachRoutePatternMatched
添加回调函数要在用户导航 View 时执行任务,现在我需要一个等效的函数来处理 View 的离开。我用的是 SplitContainer
作为父容器
onInit: function() {
this._oRouter = this.getOwnerComponent().getRouter();
this._oRouter.attachRoutePatternMatched(this._routePatternMatched, this);
},
_routePatternMatched: function(oEvent) {
var that = this;
var sRouteTargetName = oEvent.getParameter("name");
if (sRouteTargetName === "myView") {
// perform tasks if the view is opened by the user
}
},
最佳答案
你可以试试这是否有效:
navAway: function(viewName, callback) {
this._oRouter.navTo(viewName);
if(callback && typeof(callback) === "function") {
callback();
}
}
例如
this.navAway("myView", function() { //doStuff });
关于sapui5 - 查看休假事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30758411/