警告说“Id"存在并且应该被销毁 [英] Warning saying `Id` exist and should be destroyed
问题描述
大多数时候我看到以下警告,当我多次单击同一个按钮时(当调用同一个函数两次或更多次时)
Most of the time i see the following Warning, when i click on the same button for more than once (when calling the same function twice or more)
[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()`.
我应该如何销毁
它作为警告建议?或者我应该如何解决这个问题?
How should i destroy
it as the Warning suggest ? or how should i fix this ?
更新
function onPersonFound(imageData) {
var image = Ext.create('Ext.Img', {
src: "data:image/jpeg;base64," + imageData,
id: 'logo',
width: 372,
height: 140
});
推荐答案
[WARN][Ext.Component#constructor] 注册一个带有 id 的组件(
name
) 已被使用.请确保现有组件已被销毁 (Ext.Component#destroy()
.
[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()
.
警告指出您创建和销毁带有 id:name
的组件的速度太快.因此,我建议您删除该组件上的硬编码 id
属性,而是使用 itemId
.
Warning states that you are creating and destroying the component with id:name
too fast. So, I would suggest you to remove the hard-coded id
property on that component and instead use itemId
.
为什么要使用 itemId
而不是 id
?
Why to use itemId
over id
?
itemId 可用作获取对某个对象的引用的替代方法没有对象引用可用时的组件.而不是使用id 和 Ext.getCmp,itemId 和 Ext.Container.getComponent 一起使用将检索 itemId 或 id.由于 itemId 是容器的内部 MixedCollection,itemId 在本地范围为容器 - 避免与 Ext.ComponentManager 的潜在冲突这需要一个唯一的 ID.
An itemId can be used as an alternative way to get a reference to a component when no object reference is available. Instead of using an id with Ext.getCmp, use itemId with Ext.Container.getComponent which will retrieve itemId's or id's. Since itemId's are an index to the container's internal MixedCollection, the itemId is scoped locally to the container - avoiding potential conflicts with Ext.ComponentManager which requires a unique id.
这篇关于警告说“Id"存在并且应该被销毁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!