我创建了一个简单的ionic-tabs,它在屏幕顶部显示我的图标。我尝试将其包装在ionic-footer-bar中,以便将其放置在屏幕底部,但没有成功。当我这样做时,选项卡会消失。我应该如何实现我想要的外观?
<ion-footer-bar>
<ion-tabs class="tabs-icon-only tabs-stable">
...
</ion-tabs>
</ion-footer-bar>
我创建了一个简单的ionic-tabs,它在屏幕顶部显示我的图标。我尝试将其包装在ionic-footer-bar中,以便将其放置在屏幕底部,但没有成功。当我这样做时,选项卡会消失。我应该如何实现我想要的外观?
<ion-footer-bar>
<ion-tabs class="tabs-icon-only tabs-stable">
...
</ion-tabs>
</ion-footer-bar>
MyApp.config(['$ionicConfigProvider', function($ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top
}]);
你可以在这里查看文档。
要将Ionic框架的选项卡放置在Android设备屏幕的底部,只需打开您的app.js文件,在angular.module下添加以下代码行:
.config(function($ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom');
})
希望这能有所帮助。
.config(function($ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom');
})
Ionic会自动考虑平台配置,以调整诸如使用哪种过渡样式以及选项卡图标是否应该显示在顶部或底部等内容。
例如,在选项卡的情况下,对于iOS,默认设置是在底部显示,而对于Android,则在顶部显示。
Note1:需要注意的是,如果平台不是iOS或Android,则默认为iOS
Note2:如果您在桌面浏览器上开发,则会采用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');
});
您有两种方法可以更改选项卡栏的位置:
方法1:使用<ion-tabs>
的tabsPlacement
属性
<ion-tabs tabsPlacement='bottom' >
<ion-tab [root]="rootTab" tabTitle="Home"></ion-tab>
</ion-tabs>
app.module.ts
配置@NgModule({
imports: [
IonicModule.forRoot(MyApp, {
tabsPlacement : 'bottom'
})
]
})
ion-segment-button.segment-button { border-top-style: solid; border-bottom-width: 0; }
可以解决问题,但是对于border-top-width,我没有找到其他的解决办法,只能在元素的style属性中显式设置为2px。其他任何东西都会将其覆盖为3px,即使在Chrome浏览器上在元素和样式表中设置!important也似乎无法顶替它。 - yogibimbimyapp.config(['$ionicConfigProvider', function($ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top
}]);
试一下
<ion-footer><ion-tabs> <ion-tab tabTitle="返回"></ion-tab> </ion-tabs></ion-footer>