ExtJS别名vs ID [英] ExtJS alias vs id

查看:114
本文介绍了ExtJS别名vs ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白别名 vs id与ExtJS中的itemId配置属性

I don't understand the usage of alias vs id vs itemId config properties in ExtJS

app / view / foo.js

Ext.define('app.view.foo', {
    ...
    alias: 'widget.foo',         // 1
    id: 'foo',                   // or 2
    ...
});

app / controller / goo.js

Ext.define('app.controller.goo', {
    ...
    views: ['foo', ...],
    init: function() {
        this.control({
               'foo': {...},     // 1
               '#foo': {...}     // or 2
               ...
        });
        ...
    },
    ...
});

使用别名我可以使用 xtype 容易..但是通过将 id 设置为我的意见,可以获得什么优势?

With alias I can use xtype easily.. but what advantage do I gain by setting id's to my views?

推荐答案

$ c> Ext.define ,并且是在创建实例时(您似乎有此悬念)用于 xtype 的内容。应该在实例上设置 id 。当使用 Ext.create 时。这只是作为组件特定实例的唯一标识符。

An alias is set on the class definition, using Ext.define, and is what is used for the xtype when creating instances (you seem to have the hang of this). An id should be set on a class instance, e.g. when using Ext.create. This just serves as a unique identifier for a particular instance of a component.

FWIW, id 应谨慎使用。使用 itemId 更好地提供了相对使用的组件,而不是全局使用 id

FWIW, id should be used sparingly. You are much better served using itemId and referencing components relatively using that, rather than globally with an id.

这篇关于ExtJS别名vs ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆