我创建了一个简单的 ionic-tabs,在屏幕顶部显示我的图标。我试图将其包装在 ionic-footer-bar 中,以便将其放置在屏幕底部但没有成功。当我这样做时,标签消失了。我应该如何完成我想要的外观?
<ion-footer-bar>
<ion-tabs class="tabs-icon-only tabs-stable">
...
</ion-tabs>
</ion-footer-bar>
由于 Ionic 的beta 14 ( http://blog.ionic.io/the-final-beta/ ),现在有一些配置变量默认为其平台值,这意味着它们将尝试根据平台运行他们是建立在。在选项卡的情况下,iOS 默认显示在底部,Android 显示在顶部。
tabs.position
您可以通过在配置函数中的, 中设置函数来轻松“硬设置”所有平台的位置,$ionicConfigProvider
如下所示:
MyApp.config(['$ionicConfigProvider', function($ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top
}]);
您可以在此处查看文档
要将 ionicFramework 选项卡放置在 android 设备的屏幕底部,只需打开app.js文件,然后在angular.module下添加以下代码行:
.config(function($ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom');
})
希望这会有所帮助。
把它放在你的 app.js 中就可以了。
.config(function($ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom');
})
Ionic 会自动将平台配置考虑在内,以调整要使用的过渡样式以及选项卡图标应该显示在顶部还是底部。
例如,在选项卡的情况下,iOS 默认显示在底部,Android 显示在顶部。
注意1:需要注意的是,当平台不是iOS或Android时,它将默认为iOS
注意2 : 如果您在桌面浏览器上开发,它将采用 iOS 默认配置
在 app.js 文件中,您需要将 $ionicConfigProvider 注入 .config 模块并添加$ionicConfigProvider.tabs.position('bottom')
.config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); //top
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.
.
.
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/dash');
});
myapp.config(['$ionicConfigProvider', function($ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top
}]);
您有 2 种方法来更改标签栏位置:
方法1:使用tabsPlacement
属性<ion-tabs>
<ion-tabs tabsPlacement='bottom' >
<ion-tab [root]="rootTab" tabTitle="Home"></ion-tab>
</ion-tabs>
方法2:更改配置app.module.ts
@NgModule({
imports: [
IonicModule.forRoot(MyApp, {
tabsPlacement : 'bottom'
})
]
})
查看文档
尝试这个
<ion-footer><ion-tabs> <ion-tab tabTitle="Return"></ion-tab> </ion-tabs></ion-footer>