我从 AWS Amplify 教程中复制了以下内容:
const styles = {
container: { flexDirection: 'column' },
...
};
<div style={styles.container}>
但我得到:
Type '{ flexDirection: string; }' is not assignable to type 'CSSProperties'.
Types of property 'flexDirection' are incompatible.
Type 'string' is not assignable to type '"column" | "inherit" | "-moz-initial" | "initial" | "revert" | "unset" | "column-reverse" | "row" | "row-reverse" | undefined'.
我可以通过将样式内联来轻松解决这个问题,但我很好奇为什么 TypeScript 认为这是一个错误。这是一个非常基本的例子,我很惊讶 TS 在它上面失败了,所以它让我对使用 TS 保持警惕。
慕盖茨4494581
拉莫斯之舞
郎朗坤
相关分类