angular - 导出的动画未定义
问题描述
我在我的角度组件中使用淡入淡出动画。如果我在下定义组件装饰器内的动画animations: []
,它工作正常。但是,我想在不同的组件中重用动画,因此我将它移动到另一个文件并从那里导出。当我使用这个动画时,它给出了我的undefined
错误。我分析了它,它fadeInAnimation
是未定义的。这是我的代码:
淡入动画.ts
import { trigger, animate, transition, style } from '@angular/animations';
export const fadeInAnimation = trigger('fadeInAnimation', [
transition(':enter', [
// styles at start of transition
style({ opacity: 0 }),
// animation and styles at end of transition
animate('.3s', style({ opacity: 1 }))
]),
]);
我在我的组件中导入这个动画,如下所示:
import { fadeInAnimation } from './animations/fade-in.animation';
// Other imports
@Component({
selector: 'app-some-component',
templateUrl: './some.component.html',
styleUrls: ['./some.component.scss'],
animations: [ fadeInAnimation ]
})
..并在我的组件模板中使用它,如下所示:
<div [@fadeInAnimation]>Some content</div>
我无法理解为什么当我在组件内定义它时这个动画有效,而当我从另一个文件中导出它时它不起作用。我错过了什么?
有人将此设置为此问题的副本。我已经完成了其他答案中给出的所有事情,但问题仍未解决。另一个问题与创建单独的动画文件有关,我已经在这样做了。
解决方案
推荐阅读
- .net - 将 SQL 数据表传递给 Word 模板文档中预先设计的 Word 表
- vba - ADODB.Recordset : 对象关闭时不允许操作
- rest - 更新 Azure DevOps Wiki 页面使用 powershell
- javascript - 未定义代表 querySelector 类的变量 Nightmare.js
- visual-studio - 在 Subversion 中构建 Visual Studio 解决方案并保留项目引用
- python-3.x - 类型错误:get_token() 缺少 1 个必需的位置参数:'bs4'
- ios - 支持 UITextView 属性字符串中动态设置的字体
- javascript - 如何用Javascript中另一个数组的值更改数组中的特定非零值
- java - 如何让exoplayer改变质量?
- apache - 为什么我的网站一直显示未找到?