diff --git a/src/pages/exchangepage/template/main.js b/src/pages/exchangepage/template/main.js index ee94d407..4d407f55 100644 --- a/src/pages/exchangepage/template/main.js +++ b/src/pages/exchangepage/template/main.js @@ -37,6 +37,7 @@ export default class mytemplate extends React.Component{ topbar:"", top:"", toTopshow:false, + toTopFlag:false, center:"", bottom:"" } @@ -48,8 +49,7 @@ export default class mytemplate extends React.Component{ } componentDidMount(e){ - //监听滚动条滚动事件 - + let self=this; getThemeType().then(res=>{ @@ -74,13 +74,19 @@ export default class mytemplate extends React.Component{ }) }).catch(err=>{ }); - + //监听滚动条滚动事件 + this.refs.component.addEventListener('scroll',(event)=>{ + let scrolHeight=event.target.scrollTop; + console.log('滚动事件',event); + if(scrolHeight>300){ + this.setState({toTopFlag:true}); + }else{ + this.setState({toTopFlag:false}); + } + }) } - bindHandleScroll = (event) => { - console.log('滚动事件'); - console.log('滚动事件',event); - } + componentWillUnmount() { window.removeEventListener('scroll', this.bindHandleScroll); } @@ -341,10 +347,12 @@ export default class mytemplate extends React.Component{ }) } -
- + { + this.state.toTopFlag?
+ +
:null + } -
到底部了哟,没有了哦