您知道Sencha Touch是否有可能为路由实现多个前过滤器?
在下面的代码中,对于家乡路由,我需要添加更多的过滤器。
这能办到吗?
Ext.define("TestApp.controller.Router", {
extend: "Ext.app.Controller",
config: {
before: {
home: 'authenticate, filter2, filter3',
products: 'authenticate',
product: 'authenticate',
testingtwo: 'authenticate'
},
routes: {
'': 'home',
'home' : 'home',
'login' : 'login',
'products' : 'products',
'products/:id': 'product',
'testingtwo' : 'testingtwo'
}
},
发布于 2014-05-08 07:21:27
您应该将前置过滤器放在数组中。
试试这个:
config: {
before: {
home: ['authenticate', 'filter2', 'filter3'],
products: 'authenticate',
product: 'authenticate',
testingtwo: 'authenticate'
}
}
这是Ext.app.Controller源代码中的相关代码:
/**
* @private
* Massages the before filters into an array of function references for each controller action
*/
applyBefore: function(before) {
var filters, name, length, i;
for (name in before) {
filters = Ext.Array.from(before[name]);
length = filters.length;
for (i = 0; i < length; i++) {
filters[i] = this[filters[i]];
}
before[name] = filters;
}
return before;
},
https://stackoverflow.com/questions/23364139
复制相似问题