ts_react_test报错解决方法
2020-02-03 04:06
741 查看
1.. 要是给一个组件添加属性, 就要在该组件的定义前面 加上interface 接口定义
在Counter.tsx组件中 添加对属性类型的限定(对Props中的属性指定数据类型, 注意不状态State)
2.. this.setState 是要传一个参数对象, 不是重新赋值.... 低级语法错误
3.. 数据类型为--事件类型--的变量event, 不能是any, 因为需要明确数据类型, 才能显示(vscode才能提示event中有啥属性及方法)使用事件对象event 中的属性及方法
event:React.ChangeEvent 这只是指明了event的数据类型, 但还需要指明, 这个事件在哪个元素上触发的, 所以需要泛型,指定触发这个事件的元素 changeInput= (event: React.ChangeEvent<HTMLInputElement>) =>例: handleChange = ( event : React.ChangeEvent<HTMLInputElement> ) =>{}
3.1 不要忘记, 在interface State中添加上对addNumber状态变量的类型声明, addNumber: number
3.2 input的value值 是string类型 的, 需要进行转换成 number型 paseInt ( event.target.value )
4.. git push -u origin master 报错: 权限问题,解决办法
4.1 git remote rm origin
4.2 git remote add origin http://github.com/333333/react_test
转载于:https://www.cnblogs.com/andy-lehhaxm/p/10947236.html
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- 新建maven项目时没有出现src/main/java和src/test/java目录的解决方法
- SeeTest_See test 解决方法
- 新建maven项目时没有出现src/main/java和src/test/java目录的解决方法
- 【转】The test form is only available for requests from the local machine 解决方法
- python的unittest框架用例失败重运行解决方法
- No tests found matching [{ExactMatcher:fDisplayName=dataSourceTest]........错误解决方法
- ReactNative Android9.0以上打包apk后http请求不到解决方法
- angular aot编译报错 ERROR in ./src/main.ts 解决方法
- 共享器 TS ERROR WINDOWS-FAILED 错误解决方法
- React-Native在Mac系统终端命令出现adb:command not found解决方法
- react-native-echarts 在手机上 图表出现横向和纵向滚动条解决方法
- QTP:General Error while saving the test 的解决方法
- react 调用 function 的写法 及 解决 react onClick 方法自动执行
- 用ActiveX Control Test Container测试ActiveX控件时找不到控件的解决方法
- ASP.NET Web API 帮助(help)页面上没有 Test API按钮的解决方法
- Unit Test Bundle' in SDK 'iOS 8.1 解决方法
- 有关react-native POST请求造成Network request failed解决方法
- create-react-app构建项目慢的解决方法
- Service部署到服务器后出现"The test form is only available for requests from the local machine"解决方法
- 正则匹配的test方法值一直变化的原因讲解及解决方法