javascript - 如何在函数外部的 if 语句中使用函数中的更新局部变量?JS
问题描述
我正在为我的动画使用 if 语句,但它在函数之外。
这是一个例子
var index = 0;
function animate() {
index++;
}
if (window.index < 100) {
setInterval(function(){
animate();
}, 10);
}
window.requestAnimationFrame(animate)
但是如何获取索引以便更新函数之外的索引呢?
解决方案
推荐阅读
- php - 资源路线在 laravel 6 中无法正常工作
- bash - 根据实例过滤异常并路由到文件
- c++ - 这个 _com_ptr_t 移动任务有什么目的吗?
- python - 带列表理解的 7 张扑克手牌检测中的 5 张顺子
- selenium - 比较 Selenium IDE 中的值
- c++ - 如何检测我何时点击并发送更多点击?
- macos - NSURL.absoluteString 返回格式错误的文件路径
- java - 将 Java While 循环转换为多线程循环
- excel-formula - 具有 3 层 IF 结构的 Excel 公式
- python - 如何用opencv python确定螺旋叠加的位置?