antd中的Table组件的scroll参数,需要随着页面的变化而动态的变化;
this.state = {
height: document.body.clientHeight
};
componentDidMount () {
window.addEventListener('resize', this.handleHeight.bind(this));
//动态获取页面高度
}
componentWillUnmount () {
window.removeEventListener('resize', this.handleHeight.bind(this));
this.setState = () => {
return;
};
//在组件销毁时清除所有的state状态
}
handleHeight () {
const height = document.body.clientHeight;
this.setState({
height
});
}
render () {
const { height } = this.state;
return (
<Table scroll={{y: height}}></Table>
)
}