进入pages/user/user页面后,再去点击其他页面,Activity组件的定时器一直在运行呢
FuYiCai opened this issue · comments
进入pages/user/user页面后,再去点击其他页面,Activity组件的定时器一直在运行呢
找到了把componentDidMount() {
this.timer = setInterval(() => {
this.setState({ active: !this.state.active })
}, 600)
}
componentWillUnmount() {
if (this.timer) {
clearInterval(this.timer)
}
}
换成componentDidShow 和 componentDidShow就好了