- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
免责声明:我对 ExtJS(版本 5.01)比较陌生。我希望能联系到一些 ExtJS 专家来为我指明正确的方向:在 items
配置内指定 initComponent
方法时,我收到错误。下面的代码生成错误:
“未捕获类型错误:无法读取未定义的属性“项目””
当北子面板的'initComponent'函数被注释掉时,错误消失。我感觉我错过了初始化顺序的某些内容。
问:如何在 items
配置中指定子项目的 initComponent
方法?/p>
Ext.define('MyApp.view.TestView', {
extend: 'Ext.panel.Panel',
title: 'Parent',
height: 300,
layout: 'border',
items: [{
xtype: 'panel',
region: 'north',
title: 'North Child',
/* Problematic function: If commented, it works */
initComponent: function(){
console.log("test north child");
this.callParent(arguments);
}
}],
initComponent: function(){
console.log("Test parent");
this.callParent(arguments);
}
});
最佳答案
简短回答:您无法在子级上定义 initComponent
,因为您无法在子级上执行任何其他地方无法执行的操作。
InitComponent
在创建组件“MyApp.view.TestView”的实例时执行(您仅在此处使用Ext.define
定义了它)。它可以使用 Ext.create('MyApp.view.TestView',{
) 创建,或者通过创建另一个将此组件添加为项目的 View ,或者通过派生另一个组件 (extend :'MyApp.view.TestView'
).
所有子组件也会在创建 'MyApp.view.TestView' 时创建,因此子组件上的 initComponent 函数是多余的,因为没有父组件就无法创建子组件,因此父组件的 initComponent 可以是用于您想要在子组件的 initComponent 中执行的所有操作。
如果你需要某事。要在添加项目之前进行计算,您将按以下步骤操作:
Ext.define('MyApp.view.TestView', {
extend: 'Ext.panel.Panel',
title: 'Parent',
height: 300,
layout: 'border',
initComponent: function(){
var me = this,
tf = Ext.getCmp("someTextField"),
myTitle = (tf?tf.getValue():'');
Ext.applyIf(me,{
items: [{
xtype: 'panel',
region: 'north',
title: myTitle,
}]
});
this.callParent(arguments);
}
});
请参阅文档 Ext.applyIf 到底做了什么(以及它与 Ext.apply 有何不同,因为该函数有时也很方便)。
关于javascript - 项目配置中的 EXTJS 内联 initComponent 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25615965/
在 ExtJS 4 中构建应用程序时我很挣扎,其中一部分是关于何时在 initComponent() 中配置某些内容以及何时不... 例如在 Sencha 自己的MVC Application Arc
我在 initComponent() 中创建了一些项目 问题是,this.items不知何故指的是类变量,而不是实例变量。 因此,当我创建两个实例时,我最终会得到两个按钮。 items: [], in
我正在使用 Sencha Architect 2。我正在尝试使用文本搜索和显示结果的表格生成通用 UI 元素。通用意味着我想将它用于几种不同类型的搜索,例如对于用户,角色或其他内容。 所以我在这个关于
我在 ExtJs 工具栏中有一个按钮,如下所示 Ext.define('Member.view.members.MembersGrid', { extend: 'Ext.grid.Panel',
当我每次看到 initComponents(); 创建 JFrame 时在我的构造函数中。它是什么?如果我删除它会发生什么? 最佳答案 initcomponents() 是 NetBeans(我猜你正
我正在使用 Java 制作 JFrame 应用程序,我正在使用应用程序设计器在我的 JFrame 中插入组件。在 Jtextarea 中,我想显示一些文本,但该文本是由我在类中编写的函数返回的。所以我
我正在扩展 Ext 3.3 中的一个窗口,该窗口在许多地方被调用,并且自身有许多扩展。此窗口有一个可配置的字段。当这个字段为空,或者不包含任何项目时,我想显示一条错误消息,而不是继续显示窗口。这就是我
我正在 NetBeans 中构建 JApplet。当应用程序最初运行时,它需要先将一些文件下载到本地 PC 上才能正常运行。一旦完成下载这些文件,就应该绘制 GUI。如何暂停 JApplet 绘制 G
我正在使用 netBeans 编辑器创建桌面应用程序,我做错了生成initComponent() 方法中与数据库连接相关的三行代码。然后我通过在 txt 编辑器中打开 .java 文件删除了这些行,但
在 extjs 中,您始终可以通过 constructor() 扩展 extjs 类。对于从 Component 派生的类,您还可以通过 initComponent() 进行扩展。 我想知道为什么这么
MainFrame.java -JFrame public MainFrame() { initComponents(); Letters pl = new Lette
可能有更好的方法来做到这一点,如果可能的话,请为我提供如何实现它的指导,但我想知道是否有一种方法,在 Tab Click 上,显式调用该容器的 initComponent 函数?即,位于该选项卡面板内
我对使用 EXTJS 有点陌生,所以我正在使用一个教程(修改它以满足我的要求),但我遇到了一个错误。这是教程代码(我无法发布我的实际代码,但它具有相同的思想,只是方法名称不同): Ext.de
我需要在 mvc 模式的 sencha 中呈现一个模板,所以在 InitComponent 上我已经声明了一些变量,但我无法在 init 函数之外访问这些变量。我做了以下尝试 Ext.define('
我正在尝试运行 this ( http://jsfiddle.net/existdissolve/dkJb9/ ) 我的 Extjs 项目中的示例。但我读过我们可以替换使用 initComponent
我已经使用 ExtJS 一段时间了,但现在正在尝试转换我的项目以正确使用他们推荐的 MVC 风格。 我有一个 View 和一个 Controller 。我正在尝试为 boxready 声明一个事件监听
我有一个像这样的面板 var filterPanel = Ext.create('Ext.panel.Panel', { bodyPadding: 5, width:
我正在使用 Ext JS4 开发一个项目。在我们的一些类中,我们在 initComponent 函数中声明函数,然后可以将其设置为控件的处理程序。我将在下面包括一个例子。忽略类中的大部分内容,关键细节
免责声明:我对 ExtJS(版本 5.01)比较陌生。我希望能联系到一些 ExtJS 专家来为我指明正确的方向:在 items 配置内指定 initComponent 方法时,我收到错误。下面的代码生
我正在使用 Ext.define() 以 ExtJS 的新 MVC 方式编写所有组件。 我有点纠结是在 initComponent() 内部定义属性,还是简单地设置它们,如 property: 42,
我是一名优秀的程序员,十分优秀!