zoukankan      html  css  js  c++  java
  • EXTJS7 eventedConfig用法

    1. 使用eventedConfig的类需继承’Ext.Evented’
    2. eventedConfig自动并入到config中
    // Evented.js源码
    Ext.define('Ext.Evented', {
    onClassExtended: function(cls, data) {
            if (config) {
                Ext.applyIf(config, eventedConfig);
            }
            else {
                cls.addConfig(eventedConfig);
            }
        }
    });
    
    1. 通过set方法修改值的时候会触发before[configName]change和[configName]change事件
    2. 在before[configName]change事件函数中返回false可以阻止setter执行
    Ext.define('MyApp.util.Test', {
        extend: 'Ext.Evented',
    
        eventedConfig: {
            foo: null
        }
    });
    
    var test = Ext.create('MyApp.util.Test', {
        listeners: {
            beforefoochange: function (instance, newValue, oldValue) {
                return newValue !== 'bar';
            },
            foochange: function (instance, newValue, oldValue) {
               console.log('foo changed to:', newValue);
            }
        }
    });
    
    test.setFoo('bar');
    
  • 相关阅读:
    计算机基础(7)
    计算机基础(6)
    计算机基础(5)
    计算机基础(4)
    计算机基础(3)
    计算机基础(2)
    计算机基础(1)
    数组、函数
    js基础知识
    随笔3
  • 原文地址:https://www.cnblogs.com/luguojun/p/14294770.html
Copyright © 2011-2022 走看看