javascript 在 ExtJS 中 afterLayout 与布局、afterRender 与渲染等?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3430068/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
afterLayout vs layout, afterRender vs render, etc. in ExtJS?
提问by Tower
What is the difference between events like afterLayout and layout, afterRender and render? I understand the difference between beforeLayout and afterLayout -- but how does layout event differ?
afterLayout 和 layout、afterRender 和 render 等事件之间有什么区别?我了解 beforeLayout 和 afterLayout 之间的区别——但布局事件有何不同?
回答by Brian Moeskau
Note: Applies to Ext 3.x only. This was answered in 2010.
注意:仅适用于 Ext 3.x。这是在 2010 年回答的。
There is no 'layout' event, only afterLayout. From the docs, afterLayout "Fires when the components in this container are arranged by the associated layout manager" which is pretty self-explanatory. afterLayoutis only fired by Container subclasses that are responsible for laying out child components.
没有“布局”事件,只有afterLayout. 从文档中,afterLayout“在此容器中的组件由关联的布局管理器排列时触发”,这是不言自明的。 afterLayout仅由负责布置子组件的 Container 子类触发。
One the other hand, all Component subclasses (including Containers) fire the renderand afterRenderevents. The basic difference is simply that afterRenderfires later. renderfires after the DOM markup is finished rendering, but before other things that might happen (like hiding, disabling, state-restoration, etc.) during the rendering process. afterRenderfires as the very last event after all of that is complete. To fully understand this you should look at the source for the Ext.Component.render()method, which shows step-by-step how the rendering process works and when these events are fired.
另一方面,所有组件子类(包括容器)都会触发render和afterRender事件。基本的区别只是afterRender稍后触发。 render在 DOM 标记完成渲染之后触发,但在渲染过程中可能发生的其他事情(如隐藏、禁用、状态恢复等)之前触发。 afterRender在所有这些完成后,作为最后一个事件触发。要完全理解这一点,您应该查看该Ext.Component.render()方法的源代码,其中逐步显示了渲染过程的工作原理以及这些事件何时被触发。

