gpt4 book ai didi

Javascript 参数

转载 作者:行者123 更新时间:2023-11-30 07:05:48 28 4
gpt4 key购买 nike

我输入 scroll(0,10,200,10);但是当它运行时,它会传递字符串“xxpos”或“yypos”,我确实在没有撇号的情况下尝试过,但它就是行不通。

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);
}

最佳答案

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

window.setTimeout(function() {
scroller(xxpos, yypos, ttime, rrounds);
}, ttime);

关于Javascript 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9879495/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com