gpt4 book ai didi

javascript - Extjs 5 - 如何在 init 上添加路由

转载 作者:行者123 更新时间:2023-11-30 17:29:54 25 4
gpt4 key购买 nike

我的 App.controller 中有一些路由,我想在初始化时对其进行扩展(我从服务器获取路由)。附加路由的方法或功能是什么?

我正在寻找这样的东西

this.application.addRoute({
route: 'new-page',
action: 'showNewPage'
});

假设我有以下设置来澄清我的问题:

Ext.define('APP.controller.AppController',{
extend: 'Ext.app.Controller',
alias: 'appcontroller',
config : {
routes : {
'page' : {
action: 'showPage'
}
},
init: function() {

// How to add new route which will be added to config.routes of this controller?
this.addRoute({
route: 'new-page',
action: 'showNewPage'
});

},
showPage: function(){
},
showNewPage: function(){
}
});

最佳答案

原来有一个 setRoutes() 方法 :)

Ext.define('APP.controller.AppController',{
extend: 'Ext.app.Controller',
alias: 'appcontroller',
config : {
routes : {
'page' : {
action: 'showPage'
}
},
init: function() {

// Adding the routes
this.setRoutes({
'page' : {
action: 'showPage'
},
'new-page' : {
action: 'showNewPage'
}
});

},
showPage: function(){
},
showNewPage: function(){
}
});

关于javascript - Extjs 5 - 如何在 init 上添加路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23352156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com