在'@ angular/animations'中找不到Angular 4“导出'AnimationEvent" [英] Angular 4 "export 'AnimationEvent' was not found in '@angular/animations'

查看:51
本文介绍了在'@ angular/animations'中找不到Angular 4“导出'AnimationEvent"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular版本4.3.2

Angular version 4.3.2

@ angular/cli版本1.2.6

@angular/cli version 1.2.6

我将TypeScript(v2.4.2)用于要导入的组件

I'm using TypeScript (v2.4.2) for a component that imports

import {animate, AnimationEvent, state, style, transition, trigger} from '@angular/animations';

我收到警告说

在'@ angular/animations'中找不到导出的'AnimationEvent'

"export 'AnimationEvent' was not found in '@angular/animations'

其他功能(动画,状态,样式等)不会触发任何警告.我发现node_modules/@angular/animations.d.ts中的@angular代码包含

The other functions (animate, state, style, etc.) trigger no warnings. I discovered that the @angular code in node_modules/@angular/animations.d.ts includes

export * from './public_api';

和./public_api.d.ts具有

and ./public_api.d.ts has

export * from './src/animations';

和./src/animations.d.ts具有

and ./src/animations.d.ts has

export { AnimationBuilder, AnimationFactory } from './animation_builder';
export { AnimationEvent } from './animation_event';
export { AUTO_STYLE, AnimateChildOptions, AnimateTimings, AnimationAnimateChildMetadata, AnimationAnimateMetadata, AnimationAnimateRefMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationMetadataType, AnimationOptions, AnimationQueryMetadata, AnimationQueryOptions, AnimationReferenceMetadata, AnimationSequenceMetadata, AnimationStaggerMetadata, AnimationStateMetadata, AnimationStyleMetadata, AnimationTransitionMetadata, AnimationTriggerMetadata, animate, animateChild, animation, group, keyframes, query, sequence, stagger, state, style, transition, trigger, useAnimation, ɵStyleData } from './animation_metadata';
export { AnimationPlayer, NoopAnimationPlayer } from './players/animation_player';
export * from './private_export';

和./animation_event.d.ts具有接口定义

and ./animation_event.d.ts has the interface definition

export interface AnimationEvent {
    fromState: string;
    toState: string;
    totalTime: number;
    phaseName: string;
    element: any;
    triggerName: string;
}

如果我将接口定义复制到代码中,则一切正常.

If I copy the interface definition into my code everything works fine.

所有这些都与我使用过的许多其他导入非常相似,但这是唯一会生成警告的导入.

All of this is quite similar to many other imports I've used but this is the only one that generates warnings.

如何在不将接口定义复制到代码中的情况下防止这些警告?

How can I prevent these warnings without copying the interface definition into my code?

推荐答案

app-module.ts :您是否导入了BrowserAnimationsModule?

app-module.ts: Did you import BrowserAnimationsModule?

在文档中此处.

随随便便示例.

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
  imports: [ BrowserModule, BrowserAnimationsModule ],
})

如果仍然不能解决问题:

If that doesn't solve it:

  • Make a note of what system.config.js is doing in the Plunker.
  • Another related resource is a github issues thread.

如果有固定步骤,请务必说明该步骤.;-)

Be sure to comment which steps if any fixed it. ;-)

这篇关于在'@ angular/animations'中找不到Angular 4“导出'AnimationEvent"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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