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>
)
}