angular - 页面加载时出错,提供的动画触发器“动画”尚未注册
问题描述
我刚刚将我的 web 应用程序项目从 angular 4 更新到了 angular 7,我在页面加载时遇到了动画触发器的问题(ngOnInIt 方法)。我需要支持与 angular 4 和 angular 7 相同的动画效果
我已将触发器添加到我的 app.module.ts 但我仍然无法解决错误
角 4
import {animateFactory } from 'ack-angular-fx'
.ts 文件
@Component({
selector: 'abc',
templateUrl: './abc.component.html',
styleUrls: ['./abc.component.css'],
animations: [animateFactory(480, 200, 'ease-in', 100, 'animate')]
})
.html 文件
<div [@animate]="'zoomIn'">
</div>
角 7
.ts
import { trigger, transition, useAnimation } from '@angular/animations';
import { bounce, zoomIn } from 'ngx-animate';
@component({
animations: [
trigger('bounce', [transition('* => *', useAnimation(zoomIn))])
],
})
.html
<div [@animate]="'zoomIn'"></div>
我得到的实际错误消息是
Error: The provided animation trigger "animate" has not been registered!
at AnimationTransitionNamespace.push../node_modules/@angular/animations/fesm5/browser.js.AnimationTransitionNamespace._getTrigger (http://us-test-abc.ils.local:5555/vendor.js:3668:19)
at AnimationTransitionNamespace.push../node_modules/@angular/animations/fesm5/browser.js.AnimationTransitionNamespace.trigger (http://us-test-abc.ils.local:5555/vendor.js:3675:28)
at TransitionAnimationEngine.push../node_modules/@angular/animations/fesm5/browser.js.TransitionAnimationEngine.trigger (http://us-test-abc.ils.local:5555/vendor.js:4093:20)
at InjectableAnimationEngine.push../node_modules/@angular/animations/fesm5/browser.js.AnimationEngine.process (http://us-test-abc.ils.local:5555/vendor.js:5093:36)
at AnimationRenderer.push../node_modules/@angular/platform-browser/fesm5/animations.js.AnimationRenderer.setProperty (http://us-test-abc.ils.local:5555/vendor.js:73490:29)
at setElementProperty (http://us-test-abc.ils.local:5555/vendor.js:62483:19)
at checkAndUpdateElementValue (http://us-test-abc.ils.local:5555/vendor.js:62434:13)
at checkAndUpdateElementInline (http://us-test-abc.ils.local:5555/vendor.js:62383:24)
at checkAndUpdateNodeInline (http://us-test-abc.ils.local:5555/vendor.js:64732:20)
at checkAndUpdateNode (http://us-test-abc.ils.local:5555/vendor.js:64698:16)
解决方案
你的触发器被调用bounce
(正如你定义的那样,
animations: [
trigger('bounce', [transition('* => *', useAnimation(zoomIn))])
],
),所以你div
应该看起来像这样<div [@bounce]="'zoomIn'"></div>
。
试试这个,如果它仍然给你带来麻烦,请告诉我。
推荐阅读
- node.js - AWS Elastic Beanstalk - 找不到模块“hapi”
- python - Python,在循环中检测 id 和 name
- java - 我被要求使用 * 来打印“DJE”。结果不正常。我该如何解决?
- python - 使用 pyspark 过滤数组中基于 RDD 的值
- java - 我想在 jTable 的一个单元格中添加几行
- c++ - OpenCV cmake 构建总是在 Windows 中抛出错误
- sql - 带有 JOINS 的 PostgreSQL 反向查询
- ios - TableView 单元格未更新
- html - 使用 JSON 数据的 Angularjs 复选框多重过滤器
- python - 询问用户输入并在输入错误时返回问题