警告说“Id”存在,应该销毁 [英] Warning saying `Id` exist and should be destroyed

查看:123
本文介绍了警告说“Id”存在,应该销毁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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



UPDATE



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


解决方案


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


警告使用 id:name 创建和销毁组件太快。因此,我建议您删除该组件上的硬编码的 id 属性,而改为使用 itemId

为什么要使用 itemId over id


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



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 ?

UPDATE

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] Registering a component with a id (name) which has already been used. Please ensure the existing component has been destroyed (Ext.Component#destroy().

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.

Why to use itemId over 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屋!

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