About Extjs6.0 controller file is too large, modular separation

Extjs a view generally corresponding to a controller once encountered in the logical view too cumbersome to cause controller file is too large is not conducive to the maintenance and modification, so mixing function by incorporating mixins to implement modularity!

First create a view

Ext.define('Cosmo.view.main.right.property.event.EventUtil', {

  alternateClassName: ['EventUtil'],  //别名

  requires: ['Cosmo.Map', 'Cosmo.Page'],

  onAlert:function(){
      alert(1)
  }
});

Then you start mixing inside the controller file

Ext.define('Cosmo.view.main.right.property.event.EventController', {
    
    extend: 'Ext.app.ViewController',

    /** 控制器别名 */
    alias: 'controller.eventController',

    mixins: ['Cosmo.view.main.right.property.event.EventUtil'],
    
    render:function(){
        var me=this;
        me.onAlert()
    }
})

Such modularity can be achieved, so that the function can be realized according to the distinguished

Guess you like

Origin www.cnblogs.com/homehtml/p/11903430.html