将Angular 5升级到Angular 6出现错误

3
我刚从Angular 5升级到Angular 6,现在遇到了与Angular动画相关的问题。
我按照标准的升级流程进行了操作。
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli --migrate-only --from=1.7.4
ng update @angular/core
npm install rxjs-compat (most project probably need this)
ng serve

我也按照官方的升级指南(https://update.angular.io/),将我的代码从5.2升级到6版,但遇到一个错误,我无法解决。

ERROR in src/app/dispute-center/shared/services/dispute-store-service.ts(1,22): error TS2305: Module '"/var/www/html/xxx-angular/node_modules/@angular/core/core"' has no exported member 'transition'.

src/app/profile/profile-payments-and-billing/profile-payments-and-billing.component.ts(1,28): error TS2305: Module '"/var/www/html/xxx-angular/node_modules/@angular/core/core"' has no exported member 'trigger'.

src/app/profile/profile-payments-and-billing/profile-payments-and-billing.component.ts(1,37): error TS2305: Module '"/var/www/html/xxx-angular/node_modules/@angular/core/core"' has no exported member 'state'.

src/app/profile/profile-payments-and-billing/profile-payments-and-billing.component.ts(1,44): error TS2305: Module '"/var/www/html/xxx-angular/node_modules/@angular/core/core"' has no exported member 'style'.

src/app/profile/profile-payments-and-billing/profile-payments-and-billing.component.ts(1,51): error TS2305: Module '"/var/www/html/xxx-angular/node_modules/@angular/core/core"' has no exported member 'transition'.

src/app/profile/profile-payments-and-billing/profile-payments-and-billing.component.ts(1,63): error TS2305: Module '"/var/www/html/xxx-angular/node_modules/@angular/core/core"' has no exported member 'animate'.

我猜测这是因为动画模块的导入已经移动了,但是它们移动到哪个包里面了呢?

1个回答

16

从 Angular v6 的 更新日志 的重大更改部分得知:

core: 无法再从 @angular/core 导入与动画相关的函数。现在必须从 @angular/animations 导入所有动画符号。

因此,您需要将 triggertransitionanimatetriggerstate等的导入源从 @angular/core 更改为 @angular/animations


拯救了我的一天。谢谢。 - Kashif Hanif

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接