在Angular Material中,如果AnimationDuration不起作用,可以尝试以下解决方法:
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
imports: [
BrowserAnimationsModule
],
...
})
export class AppModule { }
@import '~@angular/material/prebuilt-themes/indigo-pink.css';
import { animate, style, transition, trigger } from '@angular/animations';
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css'],
animations: [
trigger('fadeInOut', [
transition(':enter', [
style({ opacity: 0 }),
animate('500ms', style({ opacity: 1 }))
]),
transition(':leave', [
animate('500ms', style({ opacity: 0 }))
])
])
]
})
export class ExampleComponent { }
在上述示例中,使用了500ms作为动画持续时间,可以根据需要进行调整。
希望以上解决方法能够帮助到你解决Angular Material中AnimationDuration不响应的问题。