带有Angular材质的AnimationDuration没有响应

时间:2018-12-27 16:43:26

标签: angular angular-material

我正在使用Angular5项目 我安装了Angular-material,但是Angular-material的animationDuration属性不起作用。我在下面粘贴了我的代码

我检查了角度动画及其所有效果

<mat-tab-group animationDuration="0ms">
    <mat-tab label="Tab One">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil odit magnam minima, soluta doloribus reiciendis molestiae placeat unde eos molestias. Quisquam aperiam, pariatur. Tempora, placeat ratione porro voluptate odit minima.</p>

    </mat-tab>
    <mat-tab label="Tab Two">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil odit magnam minima, soluta doloribus reiciendis molestiae placeat unde eos molestias. Quisquam aperiam, pariatur. Tempora, placeat ratione porro voluptate odit minima.</p>
    </mat-tab>
  </mat-tab-group>

下面是package.json文件

"dependencies": {
    "@angular/animations": "^4.0.1",
    "@angular/cdk": "^5.2.5",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/material": "^5.2.5",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "bootstrap": "^4.0.0-alpha.6",
    "chart.js": "^2.5.0",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.4.1",
    "easy-pie-chart": "^2.1.7",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.5.6",
    "screenfull": "^3.2.0",
    "web-animations-js": "^2.2.5",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "~1.7.2",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }

3 个答案:

答案 0 :(得分:0)

您是否已在组件中导入了动画模块?

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

答案 1 :(得分:0)

经过研究,我发现了这一点:[@.disabled]="true"

<mat-tab-group [@.disabled]="true">
  <mat-tab label="First"> Content 1 </mat-tab>
  <mat-tab label="Second"> Content 2 </mat-tab>
  <mat-tab label="Third"> Content 3 </mat-tab>
</mat-tab-group>

这将禁用动画。

答案 2 :(得分:0)

我的问题是我必须升级到角材版本7.3.7。

在package.json中:

"dependencies": {
   "@angular/material": "7.3.7"
}