我使用React w / Typescript,使用“DefinitelyTyped”定义。
我最近使用v16.3.9 React类型(@types/react
)从React v16.0.0升级到v16.3.0。
我以前的SVG元素看起来像这样,enable-background
作为样式属性:
import * as React from "react"
export class CaretSvgRight
extends React.PureComponent<React.SVGProps<SVGElement>, object> {
render(){
return <svg
style={{"enable-background":"new 0 0 292.359 292.359"}}
{...this.props}
>
<path d="..."/>
</svg>
}
}
使用新的输入法,我不得不更改为SVGProps类型目标的奇怪外观SVGSVGElement
类型,这需要我将enable-background
属性移到SVG
级别:
import * as React from "react"
export class CaretSvgRight
extends React.PureComponent<React.SVGProps<SVGSVGElement>, object> {
render(){
return <svg
enableBackground="new 0 0 292.359 292.359"
{...this.props}
>
<path d="..."/>
</svg>
}
}
这看起来是正确的,还是我应该做一些不同的事情来将enable-background
属性带回到样式属性中(之前的输入错误,这个属性应该在SVG
上元素,或者他们现在错了吗?)
似乎对SVG在浏览器中的显示方式(在Chrome中测试)没有任何影响 - 我应该删除整个enable-background
并不担心它吗?