4

これは、ここでの私の前の質問から導き出されます。
私はExtJs3.xで約1年間開発しており、ExtJs4に移行したいと思っています。
私は次のようにextJsファイルをコーディングすることに慣れています。

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()

私はExtJs4コードのさまざまな例を見てきましたが、正直言って少し混乱しています。
私はその方法を使うべきだと知っていExt.defineます。頭が回らないようです。
ExtJs4に変換された上記の例はどのようになりますか?

4

1 に答える 1

4

次のようになります。

Ext.define('ReportsPanel', {
    extend: 'Ext.panel.Panel',

    // default parameters
    title: 'Reports',
    layout: 'border',
    closable: true,

    // custom variables.
    foo: 'my var',
    bar: 'baz',

    constructor: function(config) {
        // ... do something in constructor if you need.


        this.callParent(arguments);
    },

    dummyFunction: function(){
        this.foo = 'bar';
        this.bar = 'my var';
    }
});
于 2011-05-11T19:42:10.067 に答える