javascript - 平滑的角度绑定更新
问题描述
我正在尝试实现一个基于 Angular 的秒表,但我无法在不闪烁的情况下更新绑定。我希望秒表每秒计数。
为了更新秒表,我使用带有回调函数的 requestAnimationFrame。
private stopWatch() {
const current = new Date();
const count = +current - +this.ffCheckinTimestamp;
this.timer = this.formatTime(count);
this.timerAnimationId = requestAnimationFrame(this.stopWatch.bind(this));
}
<div style="margin-top: 30px;">
<div class="text-center" style="font-size: 26pt;">{{timer}}</div>
</div>
在以下视频中,您可以很好地看到闪烁:www.ff-almoshof.de/flickering.mp4
有没有办法在不闪烁的情况下实现这一点?所有逻辑都在应用程序组件中。我可以通过在单独的组件中实现秒表来解决这个问题吗?
解决方案
推荐阅读
- flutter - 如何在颤动中更改时间格式?
- python - 在 Python 中,如果两个模块具有相同的名称,将导入哪个模块?
- postgresql - 如何修复“%”处或附近的 psycopg2 语法错误 -> VALUES (%s, %s, %s ...?
- r - 将 decorate_annotation 添加到 ComplexHeatmap 包中的垂直连接扰乱图
- javascript - Axios 将 id 设置为零
- python-3.x - 在命令提示符下打开 python 时出错
- postgresql - 销售分析视图中的未定义列
- angular - 如何获取组件 HTML 中的属性值?
- powershell - 尝试安装服务总线资源管理器应用程序未显示在任务管理器中?
- javascript - 如何在 WordPress 中为 divi 主题创建选项卡模块,如下所示?