Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 样式化组件';s';css';带字体脚本的道具_Typescript_Styled Components - Fatal编程技术网

Typescript 样式化组件';s';css';带字体脚本的道具

Typescript 样式化组件';s';css';带字体脚本的道具,typescript,styled-components,Typescript,Styled Components,样式化组件有一个插件,可以实现以下功能: <div css={` background: papayawhip; color: ${props => props.theme.colors.text}; `} /> props.theme.colors.text}; `} /> 是否有任何方法可以确定TypeScriptcss是所有元素的有效属性?将以下行添加到项目中的TypeScript文件中,如中所述: 或者,您可以手动将react模块类型声明-从

样式化组件
有一个插件,可以实现以下功能:

<div
  css={`
    background: papayawhip;
    color: ${props => props.theme.colors.text};
  `}
/>
props.theme.colors.text};
`}
/>

是否有任何方法可以确定TypeScript
css
是所有元素的有效属性?

将以下行添加到项目中的TypeScript文件中,如中所述:

或者,您可以手动将
react
模块类型声明-从
“styled components/cssprop”
复制/粘贴内容添加到上述文件:

import { CSSProp } from "styled-components"

interface MyTheme {} // declare custom theme type

declare module "react" {
  interface Attributes {
    css?: CSSProp<MyTheme>
  }
}
从“样式化组件”导入{CSSProp}
接口MyTheme{}//声明自定义主题类型
声明模块“react”{
接口属性{
css?:CSSProp
}
}

后一种变体还允许您自定义
css
prop主题类型。

将以下行添加到项目内的TypeScript文件中,如中所述:

或者,您可以手动将
react
模块类型声明-从
“styled components/cssprop”
复制/粘贴内容添加到上述文件:

import { CSSProp } from "styled-components"

interface MyTheme {} // declare custom theme type

declare module "react" {
  interface Attributes {
    css?: CSSProp<MyTheme>
  }
}
从“样式化组件”导入{CSSProp}
接口MyTheme{}//声明自定义主题类型
声明模块“react”{
接口属性{
css?:CSSProp
}
}

后一个变体还允许您自定义
css
prop主题类型。

对我不起作用,但谢谢我不起作用,但谢谢