角材料选项卡 SelectedIndex 0 不起作用 [英] Angular Material Tabs SelectedIndex 0 not working
本文介绍了角材料选项卡 SelectedIndex 0 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Angular 中有一个选项卡组.我希望默认情况下会选择第一个选项卡.
但是,当我将 selectedIndex
设置为 0 时,它不会选择第一个选项卡,而将其设置为 1 或 2 会选择其他选项卡.
I have a tab group in Angular. I want that by default the first tab will be selected.
However, when I set the selectedIndex
to 0, it doesn't select the first tab, while setting it to 1 or 2 does select the other tabs.
这是我的 app.component.html:
This is my app.component.html:
<mat-toolbar color="primary">
<span color="white">קשת נחושה</span>
<span class="spacer"></span>
<button mat-icon-button>
<mat-icon class="example-icon">more_vert</mat-icon>
</button>
</mat-toolbar>
<mat-tab-group mat-stretch-tabs [selectedIndex]="0" (focusChange)="selectedTab($event)">
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>home</mat-icon>
</ng-template>
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>book</mat-icon>
</ng-template>
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>message</mat-icon>
</ng-template>
</mat-tab>
</mat-tab-group>
<router-outlet></router-outlet>
推荐答案
这是一个错误,但您可以使用 2 种方式进行数据绑定,它有效
it's a bug but you can use 2 ways data binding, it works
<md-tab-group [(selectedIndex)]="value">
这篇关于角材料选项卡 SelectedIndex 0 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文