sencha規定push(),pop()方法效果很好,但只能使用在Ext.navigation.View類型的頁面裏進行,如何能使用它呢?sencha的example裏其實也有這種用法。
即時,在引入的第一個view,做空箱子,把別的不是Ext.navigation.View類型的頁面push或者pop進來,比如:在app.js處引入了Main這個navigation類型的view :
Ext.define("campSite.view.Main", {
extend: 'Ext.navigation.View',
requires: [
'Ext.form.Panel',
],
xtype : 'mainView',//定位,controller通過這個偵聽,獲取
config: {
autoDestory : false,
items : [{
xtype:'user_form'//引入xtype爲user_form的view,當然先要包含這個view才能引用
}]
}
});
在controller裏,設置偵聽:
refs : {
submit : 'button[action=submit]',//偵聽button類,action=submit的按鈕
main : 'mainView',//偵聽xtype='mainView'的view
},
control : {
submit : {
tap : 'onSubmit'//點擊的時候觸發onSubmit函數
}
}
onSubmit : function(th){
this.payment = Ext.create('campSite.view.Payment');//創建一個view,當然也要在app.js裏面,包含有這個view
this.getMain().push(this.payment);//get獲取上面refs定義的main,這是一個navigation 類型的view,可以使用push
}