apache-royale - 在运行时创建或添加部分内容
问题描述
我想在运行时添加/创建部分内容。我从 tour de gem mainContent.mxml 中看到了示例,但似乎是在应用程序启动时加载了所有部分内容。
我只想在需要时加载部分内容,而不是在应用程序启动时加载。
因此,当个别部分内容有更新时,我们不需要刷新浏览器。
<j:ApplicationMainContent localId="main" hasTopAppBar="true" hasFooterBar="true" selectedContent = "welcome_panel">
<local:WelcomeSection name="welcome_panel"/>
<local:AlertPlayGround name="alert_panel"/>
<local:ButtonPlayGround name="button_panel"/>
<local:ImagePlayGround name="image_panel"/>
<local:NumericStepperPlayGround name="numericstepper_panel"/>
<local:DateComponentsPlayGround name="datecomponents_panel"/>
<local:ComboBoxPlayGround name="combobox_panel"/>
<local:CheckBoxPlayGround name="checkbox_panel"/>
<local:MiscelaneaPlayGound name="miscelanea_panel"/>
<local:HeadingsAndText name="text_panel"/>
<local:LabelPlayGround name="label_panel"/>
<local:ListPlayGround name="list_panel"/>
<local:RadioButtonPlayGround name="radiobutton_panel"/>
<local:SliderPlayGround name="slider_panel"/>
<local:TextInputPlayGround name="textinput_panel"/>
<local:GridPlayGround name="grid_panel"/>
<local:CardPlayGround name="card_panel"/>
<local:TablePlayGround name="tables_panel"/>
<local:FormsValidationPlayGround name="form_validation_panel"/>
<local:DropDownListPlayGround name="dropdownlist_panel"/>
<local:SnackbarPlayGround name="snackbar_panel"/>
<local:TabBarPlayGround name="tabbar_panel"/>
<local:ViewStatesPlayGround name="viewstates_panel"/>
<local:LayoutsPlayGround name="layouts_panel"/>
<local:WizardPlayGround name="wizards_panel"/>
<local:PopUpPlayGround name="popup_panel"/>
</j:ApplicationMainContent>
请帮忙
解决方案
假设您没有在 mxml.xml 中声明按钮面板。您可以使用以下代码创建它:
// This creates the ButtonPlayGround view
var bp:ButtonPlayGround = new ButtonPlayGround();
// then we need to assign the name
bp.name = "button_panel";
// finally you need to add to the ApplicationMainContent container
main.addElement(bp);
现在,当您尝试展示该视图时,您将得到它。
推荐阅读
- javascript - 从localStorage的表中显示数据而不重复
- php - 如何仅在用户登录时才显示所有 li 元素中的一个?PHP
- node.js - 在 Cloud Functions 中无法进行 Firebase 身份验证
- javascript - ASP.NET JQuery 无法访问服务器和 HTML 控件
- java - Anylogic新分支抛出“无法解析为变量”错误
- ffmpeg - 硬件加速 RPI4 FFmpeg
- python - FileNotFoundError: [Errno 2] 没有这样的文件或目录?
- javascript - 如何在没有明确输入区域的情况下使用快捷方式提交表单?
- angular - 使用事件发射我想将服务数据从组件 A 传递到 B
- python - 类型错误:切片索引必须是整数或无或在零填充 CAGAN 中具有 __index__ 方法