更新 Angular 5 到 Angular 6 错误

Update Angular 5 to Angular 6 error

我刚刚从 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'.

我想是因为动画模块导入已经移动了,但是它们移动到了哪个包下?

来自 v6 的 changelog 的重大更改部分:

core: it is no longer possible to import animation-related functions from @angular/core. All animation symbols must now be imported from @angular/animations.

因此您需要将 triggertransitionanimatetriggerstate 等的导入更新为来自 @angular/animations 而不是 @angular/core.