2
我在装入应用程序,并且在导航到该页面后在ActionBar中呈现标题时遇到问题。由于ActionBar不能有一个ID我米使用可观察的viewModel至至此我设置标题属性。Nativescript页面标题在导航后设置时不呈现
-----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并提出问题! –
这应该从navigatedTo完成。你可以这样做'page.actionBar.title =“我是一个标题”' –