首页 文章

导航后设置时,Nativescript页面 Headers 无法呈现

提问于
浏览
3

我正在 Build 一个应用程序,我在导航到该页面后在ActionBar中呈现 Headers 时遇到问题 . 由于ActionBar不能使用可观察的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;
};

到目前为止我所看到的调试这个问题的是,当我关闭手机屏幕并打开它(刷新应用程序)后,操作栏 Headers 将呈现 .

找到答案(解决方法),

<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>

1 回答

相关问题