angular - Ionic 3 工具栏按钮不会从轮廓变为实心

标签 angular typescript ionic-framework ionic3

我试图将 Ionic 3 中工具栏上的按钮从“轮廓”动态更改为“实体”,但我做不到。

我的 HTML 代码如下:

<ion-toolbar>
  <ion-buttons end>
    <button ion-button 
    [outline]="testButtonOutline" 
    [color]="testButtonColor" 
    [solid]="testButtonSolid" 
    (click)="testMode()">
      {{testModeLabel}}
    </button>
  </ion-buttons>
  <ion-title left>Choose alert</ion-title>
</ion-toolbar>

我的.TS函数是:

testMode() {
  if (this.testModeState == false) {
    this.testModeLabel = 'Test Mode: On';
    this.testModeState = true;
    this.testButtonColor = 'primary';
    this.testButtonOutline = false;
    this.testButtonSolid = true;
  }
  else {
    this.testModeLabel = 'Test Mode: Off';
    this.testModeState = false;
    this.testButtonColor = 'Grey';
    this.testButtonOutline = true;
    this.testButtonSolid = false;
  }
}

当我引入 [solid]="testButtonSolid"选项时,即使 [solid] 设置为 false,[outline] 似乎也会被覆盖。

最佳答案

这里的问题是外部<ion-buttons end>按钮。您需要将其删除。如果您在对齐按钮时遇到任何问题,则可以使用 ionic grid .并且您不需要给出 solid因为它是default .

<button ion-button [outline]="testButtonOutline" [color]="testButtonColor" (click)="testMode()">
        {{testModeLabel}}
</button>

工作中stackblitz

关于angular - Ionic 3 工具栏按钮不会从轮廓变为实心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47209877/

相关文章:

ios - 带有无效签名的无效二进制文件

javascript - 视频播放器中的视频播放完毕后需要执行操作

angular - 使用 Ionic2 typescript 的传单

typescript - 在 VS 代码中启用 TSLint

angular - 使用组件而不导入

javascript - 如何使用 Angular 1.5 和 Typescript 在组件 Controller 中获取绑定(bind)值?

javascript - 无法在模板中显示值

angular - rxjs Subject.create 已弃用 - 我应该使用什么代替?

angular - angular2中具有动态货币变量的货币管道

javascript - 如何以 Angular 迭代复选框使其变得动态?