我认为我必须对错误在根标记中给出的以下类型进行编码:
No overload matches this call.
Overload 1 of 2, '(style: Styles<Theme, {}, "root">, options?: Pick<WithStylesOptions<Theme>, "flip" | "element" | "defaultTheme" | "name" | "media" | "meta" | "index" | "link" | "generateId" | "classNamePrefix">): (props?: any) => Record<...>', gave the following error.
Type 'string' is not assignable to type 'CSSProperties | CreateCSSProperties<{}> | PropsFunc<{}, CreateCSSProperties<{}>>'
问题是我只是不知道该怎么做,以前从未输入过类似的内容。您可以在此处找到代码:https://codesandbox.io/s/github/pedroRelvas/HowToTypeTheStyleRoot(可以在文件demo.tsx上找到错误)。你能给我解释一下吗?
谢谢。
答案 0 :(得分:0)
就这么简单
const useStyles = makeStyles({
root: `
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
border-radius: 3px;
font-size: 16px;
border: 0;
color: white;
height: 48px;
padding: 0 30px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
` as CSSProperties | CreateCSSProperties<{}> | PropsFunc<{}, CreateCSSProperties<{}>>,
});