div設置了height:window.innerHeight但窗口變化時不起做用的解決代碼

componentDidMount(){this

window.addEventListener('resize',this.onWindowResize());component

}rem

componentWillUnmount(){get

window.removeEventListener('resize',this.onWindowResize());List

}im

onWindowResize(){co

let newHeight = window.innerHeight-this.getHeight(100);let

setTimeout(() => {container

this.setState({containerHeight:newHeight})new

},200);

}

相關文章
相關標籤/搜索