gpt4 book ai didi

javascript - 为什么一次打印一个字母?

转载 作者:行者123 更新时间:2023-12-02 18:07:07 26 4
gpt4 key购买 nike

为什么

让我们忘记我想要做什么!这就是最终发生的事情。为什么它一次打印一个字母?

http://jsfiddle.net/m9ZAc/

检查一下^^^

<div id="container">
</div>

<script>
var ints = 0;
var quest = ["Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers…Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers…Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers…Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers…Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers…Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers…Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers…Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers…"];
setTimeout(function(){userRead.apply(this, quest)},50);
function userRead(quest) {
quest = quest;
//var num = Math.floor(Math.random() * (1000 - 100 + 1) + 600);
if(ints <= quest.length-1) {
console.log(ints);
textIt(quest[ints]);
ints++;
setTimeout(function(){userRead(quest)},50);}
else {
ints = 0;
setTimeout(function(){userRead(quest)},50);}
}
function textIt(texting) {
var app = document.getElementById('container');
var box = document.createElement('span');
box.innerHTML = texting;
app.appendChild(box);
}
</script>

最佳答案

userRead.apply(this, quest);

apply 的第二个参数是一个数组,该数组的元素成为被调用函数的单个参数

因此,userReadquest 参数现在是您向 textIt 发送单个字符的单个字符串

关于javascript - 为什么一次打印一个字母?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20002814/

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