手机Web页面滚动方案

1、设置body的overflow:hidden

2、设置可滚动区域的overflow:auto或overflow-y:auto

3、设置可滚动区域的高度

document.body.clientHeight - header高度 + 'px'

取横、坚屏REM单位的header高度

componentDidMount(){

window.addEventListener('resize', this.onWindowResize.bind(this)) 

}

componentWillUnmount() {

window.removeEventListener('resize', this.onWindowResize.bind(this))

}

onWindowResize() {

let fontSize = parseInt(document.documentElement.style.fontSize)

this.refs.overflowHeight = document.body.clientHeight - header高度 * fontSize + 'px'

}

posted @ 2017-11-21 13:56  馨月  阅读(941)  评论(0)    收藏  举报