【问题标题】:display first tab as default when page loads页面加载时默认显示第一个选项卡
【发布时间】:2018-08-04 21:13:52
【问题描述】:

log.component.html:

<clr-tabs>
<clr-tab>
    <button style="margin-left: 3% !important;" clrTabLink [routerLink]="'log1'">Log1</button>
    <ng-template [(clrIfActive)]="log1">
        <clr-tab-content>
            <div class="main-container">
                <div class="content-container">
                    <div class="content-area">
                        <router-outlet></router-outlet>
                    </div>
                </div>
            </div>
        </clr-tab-content>
    </ng-template>
</clr-tab>
<clr-tab>
    <button style="margin-left: 3% !important;" clrTabLink [routerLink]="'log2'">Log2</button>
    <ng-template [(clrIfActive)]="log2">
        <clr-tab-content>
            <div class="main-container">
                <div class="content-container">
                    <div class="content-area">
                        <router-outlet></router-outlet>
                    </div>
                </div>
            </div>
        </clr-tab-content>
    </ng-template>
</clr-tab>

route.module.ts:

 { path: 'log', component: LogComponent, children: [
    { path: 'log1', component: Log1Component },
    { path: 'log2', component: Log2Component ,pathMatch: 'full' }
   ]
 }

我想在用户点击 /log 时默认加载 log1 选项卡内容,如何使用此功能,任何指针对像我这样的初学者都有用。

目前在点击 log1 时,它会显示两个选项卡,当我点击第一个选项卡时,它会显示 tab1 的内容,我需要默认显示这个 tab1 数据

【问题讨论】:

    标签: angular typescript angular2-routing angular5 vmware-clarity


    【解决方案1】:

    这行得通吗?

     { path: 'log', component: LogComponent, children: [
        { path: '', component: Log1Component },
        { path: 'log1', component: Log1Component },
        { path: 'log2', component: Log2Component ,pathMatch: 'full' }
       ]
     }
    

    【讨论】:

    • 不用担心 =) 这可能对其他人有帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-25
    • 2021-07-26
    • 1970-01-01
    • 2014-04-27
    • 1970-01-01
    相关资源
    最近更新 更多