typescript react 相关问题(持续更新)

阅读 58

2021-09-25

1、inputchange 写回调方法时候的type


要用React.ChangeEvent<HTMLInputElement>
2、


声明state时候用useState没有声明变量类型,当调用set时候就会报错Type 'string' is not assignable to type 'never'.
需要在声明的时候const [pictures, setPictures] = useState<string[]>([]);
3、类型转换

 const address = JSON.parse(addressString) as AddressById_addressById;

相关推荐

精彩评论(0)

0 0 举报