How to change the label from back button in Ionic 2?(如何从 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.
推荐答案
您可以在您的 app.html 中设置返回按钮文本,如 ionic 链接 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',
}
})
ionic 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',
});
ionic 2 rc.0 及更高版本以及 ionic 3 中的更新
在 ionic 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 中的后退按钮更改标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 Ionic 2 中的后退按钮更改标签?
基础教程推荐
- 检查 HTML5 拖放文件类型 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
