【问题标题】:ExtJS 6.2 - issue with initConfigExtJS 6.2 - initConfig 问题
【发布时间】:2017-03-20 06:06:46
【问题描述】:

ExtJS 6.2 版

我不允许在构造函数中从我的扩展文本字段调用 initConfig()。它抛出的错误是, initConfig should not be called by subclasses, it will be called by Ext.Component(…).

由于某种原因,我不能在那里使用 callParent() 。 它在 ExtJS 5.0 中可用。有什么替代方案吗?

【问题讨论】:

  • 你为什么打电话给initConfig
  • intiConfig 将使用传递的配置初始化对象并创建 getter 和 setter。
  • 对,但是错误告诉你超类会调用它。那么为什么需要在子类中调用它呢?
  • 另外,initConfig 不会创建 getter 和 setter,这会在类定义时发生。
  • 你可以检查这个小提琴 - (这适用于 5.0,不适用于 6.2)。这只是我想要的流程(如果没有任何意义)fiddle.sencha.com/#view/editor&fiddle/1scp

标签: extjs6


【解决方案1】:

使用 Ext.apply(this, cfg) 代替 initConfig()。它会解决你的问题。

旧代码示例:

 constructor: function(cfg){
         this.initConfig(cfg);
    },

正确的代码示例:

constructor: function(cfg){
    //this.initConfig(cfg);
    Ext.apply(this, cfg);

},

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-24
    • 2023-03-22
    • 2011-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多