Extjs viewController的 control配置用处
docs.sencha.com/extjs/6.2.0/classic/Ext.app.ViewController.html#cfg-control
Adds listeners to components selected via Ext.ComponentQuery. Accepts an object containing component paths mapped to a hash of listener functions. The function value may also be a string matching the name of a method on the controller.
In the following example the updateUser
function is mapped to to the click
event on a button component, which is a child of the useredit
component.
Ext.define('MyApp.controller.Users', { extend: 'Ext.app.Controller', control: { 'useredit button[action=save]': { click: 'updateUser' } }, updateUser: function(button) { console.log('clicked the Save button'); } });
The method you pass to the listener will automatically be resolved on the controller. In this case, the updateUser
method that will get executed on the button
click
event will resolve to the updateUser
method on the controller,
See Ext.ComponentQuery for more information on component selectors.