前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >EXTJS7 config 自定义配置属性

EXTJS7 config 自定义配置属性

作者头像
路过君
发布2020-06-19 17:17:09
4310
发布2020-06-19 17:17:09
举报
文章被收录于专栏:路过君BLOG from CSDN
代码语言:javascript
复制
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);
    }
});
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/04/08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档