警告说'Id`存在并且应该被销毁

sha*_*Hwk 3 extjs sencha-touch sencha-touch-2 cordova

大多数时候我看到以下警告,当我点击同一个按钮多次(当调用相同的功能两次或更多时)

[WARN] [WARN][Ext.Component#constructor] Registering a component with a id (`name`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`.
Run Code Online (Sandbox Code Playgroud)

destroy警告建议我应该怎么做?或者我该如何解决这个问题?

UPDATE

function onPersonFound(imageData) {
           var image = Ext.create('Ext.Img', {
                                 src: "data:image/jpeg;base64," + imageData,
                                 id: 'logo',
                                 width: 372,
                                 height: 140
                                 });
Run Code Online (Sandbox Code Playgroud)

sgo*_*les 5

[WARN] [Ext.Component#constructor]注册一个name已经使用过的id()组件.请确保现有组件已被销毁(Ext.Component#destroy().

警告表明您正在以id:name太快的速度创建和销毁组件.因此,我建议您删除该id组件上的硬编码属性,而不是使用itemId.

为什么使用itemIdid

当没有对象引用可用时,itemId可以用作获取组件引用的替代方法.不要使用带有Ext.getCmp的id,而是使用带有Ext.Container.getComponent的itemId,它将检索itemId或id.由于itemId是容器内部MixedCollection的索引,因此itemId在本地作用于容器 - 避免与需要唯一ID的Ext.ComponentManager发生潜在冲突.