是否所有子项都必须在 ItemRenderer 上的 createChildren 函数上创建?
我是否需要创建所有可以在 createChildren 函数中与 itemRenderer 一起使用的对象,即使当前项目不得显示其中一些对象?
Do I need to create all objects which i will possible use with itemRenderer in createChildren function, even if the current item must not show some of them ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
createChildren()
用于创建子组件,该子组件存在于所有主机组件的生命周期中。这些子项及其计数是不可变的,就像按钮的标签或边框容器的边框一样。要创建或删除动态子项,最好使用
commitProperies()
或updateDisplayList()
。后者更可取,因为您可以创建/删除动态子项并在单段代码中执行它们的定位。createChildren()
is for creating child components which lives along all host component's life-cycle. These children and their count are immutable like label of a button or border of a border container.To create or remove dynamic children it is better to use
commitProperies()
orupdateDisplayList()
. The latter is more preferable because of you can create/remove dynamic children and perform their positioning in a single piece of code.简短的回答:不。您可以随时创建子对象
长答案:最好在您当前使用的框架内工作。 Flex 有一个方法 invalidateChildren (或类似的方法)。您应该考虑在需要显示新对象之前调用它,然后在下次调用 createChildren 时构建新对象。
当然,有时情况需要偏离,但我无法知道这是否是其中之一。
Short answer: no. You can create child objects whenever you'd like
Long answer: It is always best to work within the framework you're currently using. Flex has a method invalidateChildren (or something like that). You should consider calling that before you need to display your new objects and then build the new objects in the next call to createChildren.
Of course, sometimes situations call for deviation, but I have no way of knowing if this is one of those times.