简体   繁体   English

Ext js 4.2销毁组件

[英]Ext js 4.2 destroy component

How can I correctly destroy a component inside Ext js 4.2 According to the docs: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.Component there is no destroy method. 如何正确销毁Ext js 4.2的组件根据文档: http//docs.sencha.com/extjs/4.2.2/#!/api/Ext.Component没有destroy方法。 My components are children of a container so I have tried container.remove('componentReference') but this is giving me unexpected behaviour, so is there any way to remove the component itself. 我的组件是容器的子组件,所以我尝试了container.remove('componentReference')但这给了我意想不到的行为,所以有没有办法删除组件本身。

A component usually is destroyed when it is removed from its owning container, unless you configure your container not to do so. 除非您将容器配置为不这样做,否则组件在从其拥有容器中移除时通常会被销毁。

Refer to the autoDestroy config and the remove function of Ext.container.AbstractContainer . 请参阅autoDestroy配置和删除的功能Ext.container.AbstractContainer

Furthermore, for Ext.panel.Panel and classes extending it there is a close function, which will also result in destruction of the component, unless a different closeAction is specified. 此外,对于Ext.panel.Panel和扩展它的类,有一个close函数,除非指定了不同的closeAction ,否则它也会导致组件的破坏。

That being said, there might be scenarios where it can actually be useful to directly invoke a component's destroy function although this is marked as private, eg when it has never been rendered (for whatever reason). 话虽这么说,但是可能存在直接调用组件的destroy函数实际上有用的情况,尽管这被标记为私有,例如当它从未被渲染时(无论出于何种原因)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM