From 64ddb0f97d708e31e082dc78328131efd310a4d0 Mon Sep 17 00:00:00 2001 From: red-deng-deng <1924913374@qq.com> Date: Fri, 21 Jan 2022 15:59:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A8=A1=E6=9D=BF=E4=B8=AD?= =?UTF-8?q?=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangepage/template/main.js | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) 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 + } -
到底部了哟,没有了哦