- 博客(3)
- 收藏
- 关注
原创 react 点击按钮返回上一级路由
1、在要点击的按钮或者文字上添加<span onTouchStart={this.backClick} > </span>2. 事件编写// 点击按钮返回上一个路由backClick(){ this.props.history.go(-1) }注意: 这里的this.props必须拿到,否则点击报错 this.props如果没有需要从父组件传递,在当前组件接收...
2022-01-02 19:36:30
2391
原创 [已解决]react异常:Can‘t perform a React state update on an unmounted component
原因:react组件已经被销毁,而此时我们的异步操作(通常为调用接口更改state操作)还未结束。当我们的异步执行完成后要执行setState操作时,已经无法获得组件信息,由此造成该异常!解决方案:我们应该在组件中通过componentWillUnmount钩子函数在组件销毁的时候将异步方法撤销:componentWillUnmount() { this.setState = ()=>false;}...
2021-12-31 15:41:58
706
原创 Error: A <Route> is only ever to be used as the child of <Routes> element, never rendereddirectly.Pl
解决: 更改react-router-dom的版本,改为 5.2.0就可以了 npm i react-router-dom@5.2.0
2021-12-31 12:27:59
683
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人