extjs 如何在Ext.js中查找具有变量名的组件?

afdcj2ne  于 2023-10-18  发布在  其他
关注(0)|答案(1)|浏览(220)

我想获取组件及其禁用/可见值。
范例:

  1. this.btnForm = new baseComponent.menuItem({
  2. text: 'Form',
  3. disabled: true
  4. });
  5. var btnName;

我想通过btnName获取btnForm的禁用值。我该如何使用ComponentQuery,或者是否有其他解决方案?

zfycwa2u

zfycwa2u1#

您可以通过btnName striaghtaway使用配置名称本身获取btnForm的disabled值!您可以使用 this.btnForm.disabledthis.btnForm.isDisabled() 来返回按钮的disabled值!ExtJS中的ComponentQuery并不直接提供使用组件的变量名访问组件的方法。ComponentQuery主要基于选择器,这些选择器针对xtype、itemId或CSS类等属性。

  1. Ext.application({
  2. name: 'MyApp',
  3. launch: function () {
  4. // Creating component
  5. this.btnForm = Ext.create('Ext.button.Button', {
  6. text: 'Button',
  7. disabled: true,
  8. renderTo: Ext.getBody()
  9. });
  10. var btnName = this.btnForm.disabled;
  11. console.log(btnName)
  12. }
  13. });

相关问题