类型 '{ |cssProperties|}' 不可分配给 React 中的类型 'Properties<string | number, string & {}>'
Type '{ |cssProperties|}' is not assignable to type 'Properties<string | number, string & {}>' in React
我有这个代码:
const linkStyle = {
color: '#8954A8',
fontWeight: 'bold',
fontSize: 16,
verticalAlign: '5%',
};
const IndexPage: React.FunctionComponent = () => {
return (
<>
<a style={linkStyle} href={`${link.url}?utm_source=starter&utm_medium=start-page&utm_campaign=minimal-starter`}>link </a>
</>
}
我遇到了这个问题:
Type '{ color: string; fontWeight: string; fontSize: number; verticalAlign: string;
}' is not assignable to type 'Properties<string | number, string & {}>'.ts(2322)
index.d.ts(1842, 9): The expected type comes from property 'style' which is declared
here on type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement>'
如何解决它,为什么是我的问题的原因?
我有这个代码:
const linkStyle = {
color: '#8954A8',
fontWeight: 'bold',
fontSize: 16,
verticalAlign: '5%',
};
const IndexPage: React.FunctionComponent = () => {
return (
<>
<a style={linkStyle} href={`${link.url}?utm_source=starter&utm_medium=start-page&utm_campaign=minimal-starter`}>link </a>
</>
}
我遇到了这个问题:
Type '{ color: string; fontWeight: string; fontSize: number; verticalAlign: string;
}' is not assignable to type 'Properties<string | number, string & {}>'.ts(2322)
index.d.ts(1842, 9): The expected type comes from property 'style' which is declared
here on type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement>'
如何解决它,为什么是我的问题的原因?