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 =「我是一個標題」' –