gpt4 book ai didi

javascript - ExtJS addEvents - 它是可选的吗?

转载 作者:行者123 更新时间:2023-11-30 17:17:49 25 4
gpt4 key购买 nike

使用来自 http://www.extjs-tutorial.com/extjs/custom-events-in-extjs 的 ExtJS 示例

有人可以解释为什么我在构造函数中如下注释这两行没有什么区别吗?

代码如下:

Ext.define('Student', {
config : {
name : '',
schoolName : ''
},

mixins :
{
observable : 'Ext.util.Observable'
},

constructor : function(config){
// this.addEvents('studentNameChanged');
this.mixins.observable.constructor.call(this, config);
// this.initConfig(config);
},

updateName : function(newValue, oldValue){
this.fireEvent('studentNameChanged', newValue);
}
});

var newStudent = Ext.create('Student', { name: 'xyz' });
newStudent.on('studentNameChanged', function(name){
alert('student Name has been Chaged to ' + name);
});
newStudent.setName('John');

最佳答案

使用 addEvents 的 IIRC 在 Ext JS 3.x 及以下版本中是强制性的,在 4.x 中已弃用,并将在 5.0+ 中产生错误。不要使用它。

关于javascript - ExtJS addEvents - 它是可选的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25751132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com