4
这导致从我以前的问题here。
我一直在使用ExtJs 3.x开发大约一年,现在我想迁移到ExtJs4。
我用我的编码文件的ExtJS象下面这样:将ExtJs3转换为ExtJs4?
ReportsPanel = function(config){
config = config || {};
function dummyFunction(){
//I would usually have methods in this file also.
}
Ext.apply(config, {
title: 'Reports',
layout: 'border',
id: 'reportsPanel',
closable: 'true',
items: []
});
ReportsPanel.superclass.constructor.call(this, config);
};
Ext.extend(ReportsPanel, Ext.Panel, {
dummy: dummyFunction//Make the dummy function available to call
});
和实例这与new ReportsPanel()
无论neccessary。
我看了很多不同的ExtJs 4代码的例子,说实话我有点困惑。
我知道我应该使用Ext.define
方法。我似乎无法摆脱困境。
上面的例子应该转换成ExtJs4看起来像什么?
感谢您的答复。我将如何在Ext.define中创建私有变量和函数。另外在我的ExtJs 3代码中,我有很多'var = someVar'我将不得不将它们全部更改为'var:someVar'或者做什么最好的方法? – shane87 2011-05-12 10:53:22
据我所知,你不能声明私有变量或函数。至于你的第二个问题,你可以像属性一样分配变量,并通过“this”属性在函数内部访问它们。我更新了我的示例来演示它。 – ischenkodv 2011-05-12 14:10:42
您当然可以声明私有变量或函数,但要这样做,您需要用一个闭包来封装Ext.define,并且这些私有变量/函数会在与Ext.define相同的闭包范围内声明 – 2011-12-24 12:40:55