如何在 TabNavigator 的 Canvas 子级上获取单独的creationPolicy?

发布于 2024-09-27 20:47:27 字数 507 浏览 4 评论 0原文

阅读了有关容器创建策略(感谢 StackOverflow 中的所有参考资料)后,

我遇到了一个问题:

我有一个 TabNavigator,并且初始选项卡中的 AS 代码需要引用 第二个选项卡的组件(具有多个子项的画布)。
但在呈现该选项卡之前,第二个选项卡的组件均为空。

根据我阅读的文档,我应该能够将第二个选项卡/画布上的creationPolicy设置为“all”; TabNavigator 将实例化其所有顶级子级,即使其多视图creationPolicy =“auto”;我希望在创建子选项卡/画布时,该单视图容器的creationPolicy =“all”能够得到尊重。

但事实似乎并非如此;如果 TabNavigator 的creationPolicy =“all”,则填充第二个选项卡(但第三个、第四个……也是如此);但使用“auto”时,会创建第二个选项卡,但不会填充,即使creationPolicy =“all”。

有没有办法让选定的选项卡进行预实例化?

Having read about Container creationPolicy (thanks all the references in StackOverflow)

I have a problem/question:

I have a TabNavigator and AS code in the initial Tab needs to reference
components of second tab (a Canvas with multiple children).
But the components of the second tab are null until that Tab is rendered.

According to the documentation as I read it, I should be able to set creationPolicy on the second tab/Canvas to "all"; the TabNavigator will instantiate all its top-level children, even with its multi-view creationPolicy="auto"; and I was hoping that when creating the child Tab/Canvas, that the creationPolicy="all" of that single-view Container would be honored.

But it appears that this is not the case; if the TabNavigator has creationPolicy="all" then the second Tab is populated (but so are the third, fourth, ...); but with "auto" the second Tab is created, but not populated, even though its creationPolicy="all".

Is there a way to get just selected Tabs to pre-instantiate?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别闹i 2024-10-04 20:47:27

有没有办法让选定的选项卡进行预实例化?

不!您所看到的是预期行为。如果未创建选项卡的主要子项,则该子项无法创建其所有子项。

您可以考虑稍微重构一下您的代码;当一个组件访问另一个组件(不是它的子组件)中的数据时,会破坏封装。

Is there a way to get just selected Tabs to pre-instantiate?

No! What you are seeing is expected behavior. If the Tab's primary child is not created then that child cannot create all of it's children.

You may consider refactoring your code a bit; as one component access data in another component that is not it's child breaks encapsulation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文