Angular 中的样式方法类型“AnimationStyleMetadata”没有与类型“AnimationOptions”共有的属性的错误原因是什么?

问题描述 投票:0回答:1

在 Angular 4.4.7 中,在动画属性声明中的组件上:

`animations: [
    trigger("expand", [
      state(
        "close",
        style({
          opacity: 0,
          display: "none",
          height: 0,
        })
      ),
      state(
        "open",
        style({
          display: "block",
          opacity: 1,
        })
      ),
      transition(
        "close => open",
        animate("0.3s ease-in-out"),
        style({ overflow: "hidden", position: "relative", height: "*" })
      ),
      transition(
        "open => close",
        animate("0.3s ease-in-out"),
        style({ overflow: "hidden", position: "relative", height: "*" })
      ),
    ]),
  ]`

这一行发生错误:

style({ overflow: "hidden", position: "relative", height: "*" })

错误是:

Type 'AnimationStyleMetadata' has no properties in common with type 'AnimationOptions'.ts(2559)
(property) overflow: string

此代码适用于以前的开发人员,但 VS 代码对我显示错误。我想在继续将项目从

4.4.7
升级到版本之前清除此错误。 5.

款式类型描述说类型

AnimationStyleMetadata

`(alias) style(tokens: "*" | {
    [key: string]: string | number;
} | ("*" | {
    [key: string]: string | number;
})[]): AnimationStyleMetadata`

我不确定为什么这个错误试图将样式道具与

AnimationOptions
相关联。

angular angular-animations
1个回答
0
投票

我通过在 AnimationMetadata 属性数组周围添加 [] 解决了这个问题

 transition("open => close", [
        animate("0.3s ease-in-out"),
        style({ overflow: "hidden", position: "relative", height: "*" }),
      ]),
© www.soinside.com 2019 - 2024. All rights reserved.