Jer*_*ied 5 css dom typescript reactjs
我正在使用 typescript 进行反应,并尝试编写一个模块,该模块从 DOM 元素中获取样式对象并将其作为样式属性传递到新的 JSX 元素中。
像这样的东西:
<div style={domElement.style} />
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我遇到了打字稿错误:
<div style={domElement.style} />
Run Code Online (Sandbox Code Playgroud)
domElement.style 如下所示:
Type 'CSSStyleDeclaration' is not assignable to type 'CSSProperties'.
Types of property 'backfaceVisibility' are incompatible.
Type 'string' is not assignable to type '"hidden" | "inherit" | "-moz-initial" | "initial" | "revert" | "unset" | "visible" | undefined'.
Run Code Online (Sandbox Code Playgroud)
有没有什么方法可以使用 DOM 样式作为 React 样式而不遇到打字稿错误?
| 归档时间: |
|
| 查看次数: |
5826 次 |
| 最近记录: |