每次查看页面时如何执行代码 [英] How execute code every time that I view a page

查看:27
本文介绍了每次查看页面时如何执行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次查看页面时(每次由 splitApp.toDetail 调用页面时),我都在搜索执行代码的模式(在我的例子中是从服务器检索数据以进行可视化)或 splitApp.backDetail).我该怎么做?

I'm searching the mode to execute a code (in my case the retrieve of data to visualize from server) every time I view a page (every time the page is called by splitApp.toDetail or splitApp.backDetail). How can i do it?

附言onBeforeRenderingonAfterRendering 只在第一次执行.

P.S. The onBeforeRendering and onAfterRendering execute only the first time.

推荐答案

有适合​​您的解决方案.每次触发导航时,都会有一个名为 routeMatched 的事件.您可以在详情页面附加活动.

There is a solution for you. There is a event called routeMatched when navigation is triggered every time. You can attach the event in the detail page.

 onInit : function () {
    this._oRouter = sap.ui.core.UIComponent.getRouterFor(this);
    this._oRouter.attachRouteMatched(this.handleRouteMatched, this);
},

handleRouteMatched : function (evt) {
    //Check whether is the detail page is matched.
    if (evt.getParameter("name") !== "detail") {
        return;
    //You code here to run every time when your detail page is called.
}

这篇关于每次查看页面时如何执行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆