Better way to call superclass method in ExtJS

后端 未结 6 1439
梦如初夏
梦如初夏 2020-12-24 06:30

All the ExtJS documentation and examples I have read suggest calling superclass methods like this:

MyApp.MyPanel = Ext.extend(Ext.Panel, {
  initComponent: f         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 07:15

    I would simply change your code to:

    var $cls = MyApp.MyPanel = Ext.extend(Ext.Panel, {
      initComponent: function() {
        // do something MyPanel specific here...
        $cls.superclass.initComponent.call(this);
      }
    });
    

    That way you only keep a single reference of your class name, now $cls. Only use $cls within your class methods and you'll be fine.

提交回复
热议问题