【发布时间】:2020-02-15 20:11:30
【问题描述】:
为什么不能绑定 ion-tab-bar 的 slot 属性? 仅当平台是移动的时,我才想将标签栏放在底部,但这不起作用。有什么解决办法吗?
我的 panel.page.html:
<ion-tab-bar [slot]="tabsPlacement">
<ion-tab-button tab="foo">
<ion-label>
Foo
</ion-label>
</ion-tab-button>
<ion-tab-button tab="bar">
<ion-label>
Bar
</ion-label>
</ion-tab-button>
</ion-tab-bar>
我的 panel.page.ts 文件:
export class PanelPage implements OnInit {
tabsPlacement: string = 'bottom';
constructor(
public platform: Platform,
) {
if (!this.platform.is('mobile')) {
this.tabsPlacement = 'top';
}
}
ngOnInit() {
}
}
此外,问题与平台检测无关。问题的核心是关于 SLOTS,它们是否可绑定或是否有任何解决方法。
【问题讨论】:
-
你不能动态绑定“slot”属性。您可以尝试通过 *ngIf 来达到第一个答案所暗示的效果吗?
标签: angular ionic-framework ionic4