【问题标题】:Why can I import animation components from both @angular/animations and @angular/core?为什么我可以同时从 @angular/animations 和 @angular/core 导入动画组件?
【发布时间】:2017-11-17 09:32:26
【问题描述】:

我最近更新到 Angular 4 并检查了 animations docs 我发现我应该从 @angular/animations 导入触发器、动画和过渡。

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

然而,在我的项目中,到目前为止,我一直从 @angular/core 导入并且一切正常,即使在动画与核心分离之后也是如此。

import { ... trigger, state, style, animate, transition } from '@angular/core';

为什么 angular core 仍然持有这些动画组件?向后兼容可能吗?为什么不直接将其从核心中完全移除?

【问题讨论】:

    标签: angular angular-animations


    【解决方案1】:

    从@angular/core 的导入被弃用

    https://angular.io/api/core/animate

    此符号已移动。请改为从 @angular/animations 导入!

    我认为他们有一天会从核心中删除它们。

    【讨论】:

      【解决方案2】:

      取自changelog。它已被弃用,但您仍然可以在您的应用程序中使用它。并非所有程序员都可以在每个新版本上更新他们的应用程序。这只是一个警告,您应该更新您的代码,以便在主要版本发生时,您的迁移将是顺利的。希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 2018-02-21
        • 2020-03-27
        • 2018-12-26
        • 2017-10-03
        • 1970-01-01
        • 2020-05-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多