完整的报错是:Types of property ‘position’ are incompatible.
Type ‘string’ is not assignable to type ‘PositionProperty | undefined’.
我的代码问题在:
return {
position: 'relative'
}
TS 觉得这样不行,需要改成
return {
position: 'relative' as const,
}
或者(相信我你不会想写成这样的)
return {
position: 'relative' as 'relative',
}