EXTJS7 config 自定义配置属性

Ext.define('myComponent', {
	extend: 'Ext.Component',
	// 自定义配置属性,会自动生成getter,setter
	config: {
		prop1: null,
		...
	},
	items:[{
		xtype: 'textfield',
		// 属性不能直接绑定到组件配置上
		bind: '{vmprop1}'
	}],
	 constructor: function(config) {
	 	// 如果重载了构造函数需得要调用初始化配置
        this.initConfig(config);

        return this;
    }
    // 实现此方法会在属性设置前被调用
	applyProp1: function(newValue) {
        if (typeof pronewValue1!== 'number' || newValue< 0) {
            console.warn("Invalid prop1, must be a positive number");
            return;
        }
        return prop1;
    },
    // 实现此方法会在属性设置后被调用
    updateProp1: function(newValue, oldValue) {
    	// 更新vm属性
    	this.getViewModel().set('vmprop1', newValue);
        this.fireEvent('prop1_change', this, newValue, oldValue);
    }
});
原创文章 68 获赞 61 访问量 2937

猜你喜欢

转载自blog.csdn.net/zhoudingding/article/details/105383026
今日推荐