BrowserAnimationsModule和NoopAnimationsModule有什么区别? [英] What's the difference between BrowserAnimationsModule and NoopAnimationsModule?

查看:292
本文介绍了BrowserAnimationsModule和NoopAnimationsModule有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用新的Angular-Material版本,您需要为Angular-Animations添加模块.您可以在两个BrowserAnimationsModule和NoopAnimationsModule之间进行选择. 官方指南指出:

With the new Angular-Material release, you need to add a module for Angular-Animations. You can choose between two BrowserAnimationsModule and NoopAnimationsModule. The official guide states:

某些Material组件依赖于Angular动画模块 为了能够进行更高级的转换.如果你想要这些 要在您的应用中正常播放动画,您必须安装 @ angular/animations模块,并在其中包含BrowserAnimationsModule 您的应用.

Some Material components depend on the Angular animations module in order to be able to do more advanced transitions. If you want these animations to work in your app, you have to install the @angular/animations module and include the BrowserAnimationsModule in your app.

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

@NgModule({
  ...
  imports: [BrowserAnimationsModule],
  ...
})
export class PizzaPartyAppModule { }

如果您不想在项目中添加其他依赖项,则可以使用NoopAnimationsModule.

If you don't want to add another dependency to your project, you can use the NoopAnimationsModule.

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

@NgModule({
  ...
  imports: [NoopAnimationsModule],
  ...
})
export class PizzaPartyAppModule { }

我不太明白这里有什么区别.似乎完全相同:)两个模块之间有什么区别?

I don't quite get what is the difference here. Seems to be exactly the same :) What's the difference between the two modules?

推荐答案

正如名称noop(无操作")所说,该模块不执行任何操作.这是一个实用程序模块,可模拟真实的动画模块,但实际上并未设置动画.

As the name noop ("no operation") says, that module doesn't do anything. It is a utility module that mocks the real animation module but doesn't actually animate.

这在动画速度太慢的平台上或在单元动画(如果您不希望实际参与的动画中进行单元测试)中很方便.

This can be handy on platforms where animation would be too slow, or for unit testing, if animation isn't involved in what you actually want to test.

这篇关于BrowserAnimationsModule和NoopAnimationsModule有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆