Ext.lang = function()到Ext.define

时间:2015-09-07 07:54:08

标签: javascript oop extjs refactoring extjs4.1

我有一个应用程序,在发布时做了这个丑陋的事情:

                Ext.lang = function (langId) {
                    if (Ext.local[langId]) {
                        return Ext.local[langId];
                    }
                    if (!localStorage.getItem('localLangBackup')) {
                        delete window.localStorage.localLang;
                        localStorage.setItem('localLangBackup', true);
                    }
                    return langId;
                }

我很想重构这件事:

Ext.define('Ext.lang',{whatever gous in here...})

但到目前为止没有运气,因为当我尝试时:

 Ext.define('Ext.lang', function (langId) {
        if (Ext.local[langId]) {
            return Ext.local[langId];
        }
        if (!localStorage.getItem('localLangBackup')) {
            delete window.localStorage.localLang;
            localStorage.setItem('localLangBackup', true);
        }
        return langId;
    });

我得到了

  

Class.extend不是函数

0 个答案:

没有答案