参考:https://blog.csdn.net/weixin_43233914/article/details/107958445
1.环境
"react": "^16.13.1",
"react-router-dom": "^5.2.0",
2.在入口文件添加以下代码
import { withRouter } from "react-router-dom";
componentDidUpdate() {
console.log("===",window.location.pathname);
}
export default withRouter(App);