react的location.query改变时组件不会重新执行didmount?

class Page extends Component{

 componentDidMount(){
    const {location} = this.props;
   if(!location.query.id){
    history.replace('/url?id=1')
    }
 }
}
````
例如上面的代码,当一个页面,如果没有id时,给他默认id,但是这样执行后,组件的didMount没有重新执行。
阅读 644
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题