首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Sencha触觉2滤波器前的多路

Sencha触觉2滤波器前的多路
EN

Stack Overflow用户
提问于 2014-04-29 12:03:54
回答 1查看 233关注 0票数 3

您知道Sencha Touch是否有可能为路由实现多个前过滤器?

在下面的代码中,对于家乡路由,我需要添加更多的过滤器。

这能办到吗?

代码语言:javascript
运行
复制
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'
        }
    },
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-08 07:21:27

您应该将前置过滤器放在数组中。

试试这个:

代码语言:javascript
运行
复制
config: {
     before: {
        home: ['authenticate', 'filter2', 'filter3'],
        products: 'authenticate',
        product: 'authenticate',
        testingtwo: 'authenticate'
    }
}

这是Ext.app.Controller源代码中的相关代码:

代码语言:javascript
运行
复制
/**
 * @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;
},
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23364139

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档