We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@nutui/nutui-react
2.3.6
weapp, alipay
https://github.com/jdf2e/nutui-react/blob/next/src/packages/countdown/countdown.taro.tsx
CountDown组件在倒数结束时调用onEnd会存在调用多次
在未设置millisecond为true的时候, CountDown组件的onEnd方法在秒数等于0时只被调用一次
在未设置millisecond为true的时候, CountDown组件的onEnd方法被在秒数等于0时被调用了多次
No response
在源码tick方法中, 由于Date.now()获取毫秒级时间, 在tick方法中秒数已经等于0的时候, 毫秒还是会大于0,remainTime 大于0 会使tick方法会存在多次自我调用, 所以导致我未开启毫秒级渲染时, onEnd被多次调用
const tick = () => { stateRef.current.timer = requestAnimationFrame(() => { if (stateRef.current.counting) { const currentTime = Date.now() - stateRef.current.diffTime const remainTime = Math.max( stateRef.current.handleEndTime - currentTime, 0 ) stateRef.current.restTime = remainTime setRestTime(remainTime) if (!remainTime) { stateRef.current.counting = false pause() onEnd && onEnd() } if (remainTime > 0) { tick() } } }) }
The text was updated successfully, but these errors were encountered:
irisSong
No branches or pull requests
NutUI React 包名
@nutui/nutui-react
NutUI React 版本号
2.3.6
平台
weapp, alipay
重现链接
https://github.com/jdf2e/nutui-react/blob/next/src/packages/countdown/countdown.taro.tsx
重现步骤
CountDown组件在倒数结束时调用onEnd会存在调用多次
期望的结果是什么?
在未设置millisecond为true的时候, CountDown组件的onEnd方法在秒数等于0时只被调用一次
实际的结果是什么?
在未设置millisecond为true的时候, CountDown组件的onEnd方法被在秒数等于0时被调用了多次
环境信息
No response
其他补充信息
在源码tick方法中, 由于Date.now()获取毫秒级时间, 在tick方法中秒数已经等于0的时候, 毫秒还是会大于0,remainTime 大于0 会使tick方法会存在多次自我调用, 所以导致我未开启毫秒级渲染时, onEnd被多次调用
The text was updated successfully, but these errors were encountered: