什么时候
function StyleMixin(base: React.CSSProperties) {}
StyleMixin({
fontWeight: 'bold',
lineHeight: 1,
textAlign: 'center',
[someVariable]: {
fontSize: '1rem',
}
}
在[someVariable]
中,它说
TS2345:类型参数 '{ fontWeight: "bold"; 线高:数字;文本对齐:“中心”;...' 不能分配给“CSSProperties”类型的参数。对象字面量只能指定已知属性,并且“[someVariable]”类型不存在于“CSSProperties”中。
如何解决这个问题?