problem
通过style inline方式+style object设定样式
<div style={parentStyle} ref={parentRef}>
{/*...*/}
</div>
const parentStyle = {
width: '60vw',
height: '20vw',
color: '#fff',
backgroundColor: 'darkred',
'display': 'flex',
'alignItems': 'center',
'flexDirection': 'column',
'justifyContent': 'space-around'
}
error
编译报错:
Type 'string' is not assignable to type 'FlexDirection | undefined'. TS2322
solution
'flexDirection': 'column'
=》改为:'flexDirection': 'column' as 'column'