- html
<button #myButton1 ion-button color="primary" class="button1" (click)="changeStyle1()">Click me1</button>
- scss
.button1 {
opacity: 1;
transition: 2s linear !important;
}
- ts
//引用
import { Component,ViewChild,Renderer,ElementRef } from '@angular/core';
@ViewChild('myButton1',{read:ElementRef}) myButton1;
constructor( public renderer:Renderer)
{
}
changeStyle1()
{
this.renderer.setElementStyle(this.myButton1.nativeElement,"opacity","0");
}
this.renderer.setElementStyle(this.myButton1.nativeElement,"style参数"," value");