【发布时间】:2016-03-24 03:09:52
【问题描述】:
我正在构建一个应用程序,但在导航到该页面后在 ActionBar 中呈现标题时出现问题。由于 ActionBar 不能有一个 id 我使用可观察的 viewModel 在其中我设置了 title 属性。
-----xml-----
<Page.actionBar>
<ActionBar title="{{ name }}">
</ActionBar>
</Page.actionBar>
-------------
------js-----
exports.pageLoaded = function(args) {
page = args.object;
var navData = page.navigationContext;
viewModel.set("name",navData.name);
page.bindingContext = viewModel;
};
到目前为止,我在调试此问题时所看到的是,当我关闭手机屏幕然后打开它(刷新应用程序)时,将呈现操作栏标题。
找到答案(一种解决方法),
<ActionBar>
<ActionItem ios.systemIcon="12" android.systemIcon="ic_menu_search" tap="showSearch" />
<ActionItem android.systemIcon="ic_menu_moreoverflow" tap="logout" text="Logout" android.position="popup" />
<ActionBar.titleView>
<StackLayout orientation="horizontal">
<Label text="{{ name }}" />
<Image src="res://app_icon" />
</StackLayout>
</ActionBar.titleView>
【问题讨论】:
-
这也发生在我的应用程序中。前往 GitHub 并提出问题!
-
这应该从导航到完成。你可以这样做
page.actionBar.title="i am a title"
标签: nativescript