今天在使用Ant Design中提供的布局容器的时候,明明是它一个类组件,但在componentDidMount中输出this.props的时候却得到了一个空对象。
componentDidMount(){
console.log(this.props)
} //结果 ==> {}
这样将无法获取到history等数据,进而难以实现路由跳转等操作。
解决方法:
将结尾暴露的方式进行修改:
原本的:
export default () => <SiderDemo />;
修改后:
export default SiderDemo;
修改后便可获取history,match,location等数据,问题解决。