首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >步骤:不要更改图标

步骤:不要更改图标
EN

Stack Overflow用户
提问于 2022-04-24 12:32:52
回答 1查看 228关注 0票数 1

我正在使用Stepper组件。

代码语言:javascript
复制
<mat-stepper orientation="vertical">
  <mat-step state="home">
    <ng-template matStepLabel>Step 1</ng-template>
    <ng-template matStepContent>
      <p>This content was rendered lazily</p>
      <button mat-button matStepperNext>Next</button>
    </ng-template>
  </mat-step>
  <mat-step state="form">
    <ng-template matStepLabel>Step 2</ng-template>
    <ng-template matStepContent>
      <p>This content was also rendered lazily</p>
      <button mat-button matStepperPrevious>Back</button>
      <button mat-button matStepperNext>Next</button>
    </ng-template>
  </mat-step>
  <mat-step state="last">
    <ng-template matStepLabel>Step 3</ng-template>
    <p>This content was rendered eagerly</p>
    <button mat-button matStepperPrevious>Back</button>
  </mat-step>

  <!-- changed step icons -->
  <ng-template matStepperIcon="home">
    <mat-icon>home</mat-icon>
  </ng-template>
  <ng-template matStepperIcon="form">
    <mat-icon>format_align_center</mat-icon>
  </ng-template>
  <ng-template matStepperIcon="last">
    <mat-icon>done_all</mat-icon>
  </ng-template>
</mat-stepper>

每当用户单击某个步骤时,我都可以更改该图标,但只要该步骤不活动,图标就会被编辑或完成。我希望自定义图标始终保持不变。因此,当您单击另一个步骤时,前面的步骤不应该更改为home图标。

我该怎么做?

请参阅斯塔克布利茨

EN

回答 1

Stack Overflow用户

发布于 2022-08-26 23:39:24

您可以通过定义与自定义步骤图标相同的自定义“编辑”和“已完成”图标来做到这一点。

代码语言:javascript
复制
<!-- change default 'edit' & 'done' icon -->
<ng-template matStepperIcon="edit" let-index="index">
  <ng-container [ngSwitch]="index">
    <mat-icon *ngSwitchCase="0">home</mat-icon>
    <mat-icon *ngSwitchCase="1">format_align_center</mat-icon>
    <mat-icon *ngSwitchCase="2">done_all</mat-icon>
  </ng-container>
</ng-template>
<ng-template matStepperIcon="done" let-index="index">
  <ng-container [ngSwitch]="index">
    <mat-icon *ngSwitchCase="0">home</mat-icon>
    <mat-icon *ngSwitchCase="1">format_align_center</mat-icon>
    <mat-icon *ngSwitchCase="2">done_all</mat-icon>
  </ng-container>
</ng-template>

见编辑后的斯塔克布利茨

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71988449

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档