Javascript参数

Tan*_*lis 1 javascript

我输入卷轴(0,10,200,10); 但是当它运行时,它传递字符串"xxpos"或"yypos",我确实尝试了它没有appostraphes,但它只是没有工作.

scroll = function(xpos,ypos,time,rounds){
    var xxpos = xpos*1;
    var yypos = ypos*1;
    var rrounds = rounds*1;
    var ttime = time*1;
    x = 0;
    xyz=window.setInterval("scroller('xxpos','yypos','ttime','rrounds')",ttime);
}
function scroller(xpos,ypos,time,rounds){
    alert(xpos + ypos + time + rounds);
}
Run Code Online (Sandbox Code Playgroud)

Ser*_*sev 6

不要使用字符串,使用闭包(匿名函数).

window.setTimeout(function() {
  scroller(xxpos, yypos, ttime, rrounds);
}, ttime);
Run Code Online (Sandbox Code Playgroud)