如何在Ionic 2中更改后退按钮的标签? [英] How to change the label from back button in Ionic 2?

查看:137
本文介绍了如何在Ionic 2中更改后退按钮的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码:

<ion-navbar *navbar>
</ion-navbar>

后退按钮已启用。但我需要自定义它(图标或标签)。可能吗?
在docs / api中找不到任何内容。

the back button is enabled. But I need to customize it (the icon or the label). Is it possible? Can't find anything in the docs/api.

推荐答案

您可以在应用中设置按钮文本。离子链接中提到的html http://ionicframework.com/docs/v2/api/ config / Config

you can set back button text in your app.html as mentioned in the ionic link http://ionicframework.com/docs/v2/api/config/Config

@App({
  template: `<ion-nav [root]="root"></ion-nav>`
  config: {
    backButtonText: 'Go Back',
    iconMode: 'ios',
    modalEnter: 'modal-slide-in',
    modalLeave: 'modal-slide-out',
    tabbarPlacement: 'bottom',
    pageTransition: 'ios',
  }
})

离子2 beta 8更新

import {ionicBootstrap} from 'ionic-angular';

ionicBootstrap(AppRoot, customProviders, {
  backButtonText: 'Go Back',
  iconMode: 'ios',
  modalEnter: 'modal-slide-in',
  modalLeave: 'modal-slide-out',
  tabbarPlacement: 'bottom',
  pageTransition: 'ios',
});

离子2 rc.0及以上更新,以及离子3

在离子2 rc.0及更高版本中,我们需要在进入数组下的 app.module.ts 中包含配置。

In ionic 2 rc.0 and up, we need to include the configs in app.module.ts under imports array.

@NgModule({   
 declarations: [
    MyApp,
    Home   
 ],   
 imports: [
    IonicModule.forRoot(MyApp, {
      tabsPlacement: 'top',
      backButtonText: 'Back'
     })],
 bootstrap: [IonicApp],
 entryComponents: [
    MyApp,
    Home   ],
 providers: [MyService]
})

这篇关于如何在Ionic 2中更改后退按钮的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆