Angularmat-tab被快速选择时自动切换选项卡的问题。
创始人
2024-10-28 07:01:16
0

使用MatTabNav部分的_selectedIndex更改事件,并添加一个小延迟以解决切换太快的问题。

HTML模板:


    

组件:

import { Component, ViewChild } from '@angular/core';
import { MatTabGroup } from '@angular/material';
import { Observable, of } from 'rxjs';
import { delay } from 'rxjs/operators';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  @ViewChild('matTabs') matTabs: MatTabGroup;
  tabs = ['Tab 1', 'Tab 2', 'Tab 3'];

  onTabChange(event: any) {
    // ...your code
  }

  onSelectedIndexChange(event: any) {
    // Add a little delay to avoid tab toggling
    const observable: Observable = of(event).pipe(delay(50));
    observable.subscribe(() => {
      this.matTabs.selectedIndex = event.index;
    });
  }
}

相关内容

热门资讯

透视科普!epoker免费透视... 透视科普!epoker免费透视脚本(透视)wepoker怎么看牌型,教程要领(有挂头条)-哔哩哔哩1...
透视揭露!wepoker透视脚... 透视揭露!wepoker透视脚本免费app(透视)wpk私人局辅助是真的吗,教程手册(有挂分析)-哔...
透视曝光!aapoker辅助怎... 透视曝光!aapoker辅助怎么用(透视)wpk插件辅助,教程攻略(有挂讲解)-哔哩哔哩1、打开软件...
透视解密!xpoker透视辅助... 透视解密!xpoker透视辅助(透视)fishpoker透视底牌,教程操作(真是有挂)-哔哩哔哩1、...
透视透视!聚星ai辅助工具收费... 透视透视!聚星ai辅助工具收费多少(透视)wepoker有透视吗,教程方式(有挂解密)-哔哩哔哩1、...
透视普及!如何判断wpk辅助软... 透视普及!如何判断wpk辅助软件的真假(透视)wepoker透视脚本免费使用视频,教程手册(有挂实锤...
透视辅助!aapoker透视怎... 透视辅助!aapoker透视怎么用(透视)德普之星透视辅助,教程方针(确实有挂)-哔哩哔哩1、每一步...
透视有挂!pokerrrr2辅... 透视有挂!pokerrrr2辅助(透视)hhpoker一直输有挂吗,教程法子(果真有挂)-哔哩哔哩h...
透视关于!hhpoker脚本下... 透视关于!hhpoker脚本下载(透视)wepoker怎么买辅助,教程方式(有挂方式)-哔哩哔哩1、...
透视透视!wepoker透视脚... 您好,wepoker亲友圈有用吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【48527505...