Ext.regController('News', { // index action index: function(options) { if ( ! this.indexView) { this.indexView = this.render({ xtype: 'NewsIndex', }); } var backBtn = this.application.viewport.query('#backBtn')[0]; backBtn.show(); backBtn.setHandler(function() { Ext.dispatch({ controller: 'Home', action: 'index', historyUrl: 'Home/index', // animation: { type: 'slide', reverse: true, }, }); }); this.application.viewport.setActiveItem(this.indexView, options.animation); }, });
现在新闻控制其索引视图为(NewsIndexView.js):
App.views.NewsIndex = Ext.extend(Ext.List, { store: 'NewsItems', itemTpl: '{title}, <span class="date">{date}</date>', }); Ext.reg('NewsIndex', App.views.NewsIndex);
正像我们前面所见,我们已经采用了 Ext.List 组件来显示新闻.