好吧,所以我有这个原型对象Stage,除了这个递归调用之外,它的每个部分都有效.
Stage.prototype.start = function(key) {
//var maxScrollLeft = document.getElementById("content").scrollWidth;
$content.scrollLeft($content.scrollLeft() + this.initspeed);
if(key < this.maxScrollLeft || key > 0) {
setTimeout(function() {
this.start(key+2);
},1);
}else{
console.log("stop");
}
}
Run Code Online (Sandbox Code Playgroud)
我试图使用this.start();在这个if语句中调用Stage.prototype.start.但是我总觉得
Uncaught TypeError: Object [object global] has no method 'start'
我觉得它与匿名函数中的调用有关,关于如何解决这个问题的任何想法?
所以我正在编写一个 for 循环并遇到一些错误,以了解我写的错误
#! /bin/bash
b=${1:- 10}
echo $b
for i in {0..$b}
do
echo "$i"
done
Run Code Online (Sandbox Code Playgroud)
所以如果我跑./forloop.sh 10
我明白了
10
{0..10}
Run Code Online (Sandbox Code Playgroud)
当我有一个变量作为第二个参数时,为什么范围不起作用?