zoukankan      html  css  js  c++  java
  • tab切换组件nz-tab

    <nz-card [nzBordered]="true" nzTitle="卡片标题">
      <nz-card style=" 100%;" nzTitle="Card title" [nzExtra]="extraTemplate">
        <nz-card-tab>
          <nz-tabset nzSize="large" [(nzSelectedIndex)]="selectIndex">
            <nz-tab [nzTitle]="item.title" *ngFor="let item of tabs" (nzClick)="tabTo(item)"></nz-tab>
          </nz-tabset>
        </nz-card-tab>
        <router-outlet></router-outlet>
      </nz-card>
    </nz-card>
    import { Component, OnInit } from '@angular/core';
    import { Router } from '@angular/router';
    @Component({
      selector: 'app-card-whole-consume',
      templateUrl: './card-whole-consume.component.html',
      styles: []
    })
    export class CardWholeConsumeComponent implements OnInit {
      selectIndex = 0;
      tabs: any[] = [
        {
          key: 'dashboard',
          title: '标题1'
        }, {
          key: 'department-salary-setting',
          title: '标题2'
        }
      ];
      constructor(private router: Router) { }
      ngOnInit() {
        this.initTab();
      }
      initTab() {
        // 设置再次刷新页面时还是显示之前的tab
        const key = this.router.url.substr(this.router.url.lastIndexOf('/') + 1);
        const idx = this.tabs.findIndex(w => w.key === key);
        this.selectIndex = idx;
        this.router.navigateByUrl(`/cardWhole/${this.tabs[this.selectIndex].key}`);
      }
      tabTo(tab) {
         this.router.navigateByUrl(`/cardWhole/${tab.key}`);
      }
    }
  • 相关阅读:
    属性与字段的区别
    修改LVDS支持1024*600分辨率
    Altium designer 10如何设置标题栏
    嵌入式C开发人员的最好的0x10道笔试题
    进程线程及堆栈关系的总结
    GDB调试
    c语言
    如何使用autotools生成Makefile
    ubuntu NFS
    Ubuntu安装配置TFTP服务
  • 原文地址:https://www.cnblogs.com/yuyedaocao/p/11002279.html
Copyright © 2011-2022 走看看