J. *_*ers 5 typescript reactjs material-ui jss
我正在构建一个React应用程序,并且正在使用material-ui作为我的组件。我想知道如何赋予!important样式一种属性?
我尝试了这个:
<Paper className="left"...>
Run Code Online (Sandbox Code Playgroud)
我正在使用withStyles和WithStyles。然后在我的styles.ts:
left: {
display: "block",
float: "left!important",
},
Run Code Online (Sandbox Code Playgroud)
但这会引发错误:
[ts] Type '"left!important"' is not assignable to type '"right" | "none" | "left" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "inline-end" | "inline-start" | undefined'.
index.d.ts(1266, 3): The expected type comes from property 'float' which is declared here on type 'CSSProperties'
(property) StandardLonghandProperties<TLength = string | 0>.float?: "right" | "none" | "left" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "inline-end" | "inline-start" | undefined
Run Code Online (Sandbox Code Playgroud)
将!importantMaterial-ui与TypeScript一起使用时,如何分配标志?
您可以投放它。例如:
left: {
display: "block",
float: "left!important" as any,
},
Run Code Online (Sandbox Code Playgroud)
要么
left: {
display: "block",
float: "left!important" as "left",
},
Run Code Online (Sandbox Code Playgroud)
这是一个操场的例子。
| 归档时间: |
|
| 查看次数: |
2358 次 |
| 最近记录: |