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;
    });
  }
}

相关内容

热门资讯

玩家必备攻略!wepoker破... 玩家必备攻略!wepoker破解器有用吗(辅助挂)都是有挂(有挂解密辅助器)1、上手简单,内置详细流...
分享认知!hhpoker真的有... 分享认知!hhpoker真的有透视吗(辅助挂)其实有挂(新版有挂辅助工具)1、每一步都需要思考,不同...
揭秘攻略!智星德州插件最新版本... 揭秘攻略!智星德州插件最新版本更新内容详解(辅助挂)都是是有挂(详细教程辅助技巧)能透视中分为三种模...
实操分享!约局吧德州有挂吗(辅... 实操分享!约局吧德州有挂吗(辅助挂)本来真的有挂(有挂秘籍辅助攻略)1、玩家可以在线上大神俱乐部对游...
玩家攻略!hhpoker作弊码... 玩家攻略!hhpoker作弊码(辅助挂)其实真的有挂(有挂神器辅助技巧)1、点击下载安装,脚本分类一...
查到实测辅助!hhpoker到... 查到实测辅助!hhpoker到底可以作弊吗(辅助挂)切实有挂(竟然有挂辅助软件)1、破解器简单,机器...
推荐十款!wepoker游戏的... 推荐十款!wepoker游戏的安装教程(辅助挂)切实是真的有挂(竟然有挂辅助脚本)1、上手简单,内置...
必备攻略!hhpkoer辅助器... 必备攻略!hhpkoer辅助器(辅助挂)都是真的有挂(揭秘有挂辅助技巧)辅助器是一种具有地方特色的麻...
总算了解!wepoker有辅助... 总算了解!wepoker有辅助器吗(辅助挂)切实存在有挂(有挂方法辅助软件)1、金币登录送、破产送、...
记者爆料!wepoker开辅助... 记者爆料!wepoker开辅助能查到吗(辅助挂)切实是有挂(有挂解密辅助方法)1、游戏颠覆性的策略玩...