sencha route實現瀏覽器及Android返回按鈕頁面返回

來源:互聯網
上載者:User
sencha如果不做設定,是一個framework頁面,當點擊瀏覽器返回或者Android的返回鍵的時候會跳出頁面或整個程式
所以需要實現route路徑
網上麼有特別詳細的說明,研究了很久分享一個
首先,需要在main的地方開始就加入曆史路徑。在app.js
launch: function() {
//增加曆史路徑,設定main為home
this.getApplication().getHistory().add(Ext.create('Ext.app.Action', {
            url: 'home'
        }));
//初始化main
Ext.create('MBAPeople.view.Main', {fullscreen:true});
}
其次,在controller中定義route事件
routes: {
            'home': 'homejump',
            'changepass':'changejump'
        },
home 是名字,後面的是方法
changejump:function(){
        var form = this.getChangepassword();
        Ext.Viewport.setActiveItem(form)
    },
    homejump:function(){
        var form = this.getMainview();
        Ext.Viewport.setActiveItem(form)
    },
然後,就在相應button的事件中調用
在點擊changepassword按鈕中寫入不是setActiveitem,而是history
onBtnTap:function(){
this.getApplication().getHistory().add(Ext.create('Ext.app.Action', {
                 url: 'changepass'
                 }));
}
而在返回按鍵可以直接使用                            history.back();
handler: function() {
                            history.back();
                        }

這樣,在我們初始化main的時候,大家會發現首頁地址為localhost/app/#home,而跳轉頁面地址為localhost/app/#changepass,成為了兩個頁面,自然可以實現返回按鈕

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.