Ext.apply xtype 是什么意思?

What's Ext.apply xtype means?

我看到一个项目:

 initComponent: function() {

        var me = this;

        Ext.apply(me, {
            items: [
                {
                    xtype: 'stockform'
                }
            ]
        });

        me.callParent(arguments);
    }

这是什么意思?请告诉我。 我知道 Ext.apply() 用于简化从源对象到目标对象的许多属性的复制

var x = {a: 1, c:3, e:5};
Ext.apply(x, {b:2, d:4, f:6});

console.log(x); // Object {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}

它用于为给定对象应用给定属性。 在您的情况下,您的组件将使用 属性 items 进行扩展,它具有类型为 stockform 的内部组件。 xtype 是 shortcat 类型。

在 ExtJs 库中或您的项目中存在定义了 xtype stockform 的组件。通过添加 属性 alias: "widget.stockform".

为组件定义 xtype stockform

这两个问题合二为一,事实上:

  1. Ext.apply 的作用是什么?
  2. 什么是 xtype

回复 1:Ext.apply 将(通常)2 个对象作为参数:targetsource 并将所有属性从源对象复制到目标对象。

回复2:xtype是一个组件的简称(class),一个别名。详见“What is an xtype ... and other types”一文。