效果预览:
手速不够快,实际上是整体都是一个个崩出来的
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="width:100%; margin:0px auto">
<div id="language_two">
</div>
</div>
<script language="javascript">
var index=0;
let aa =
`我是一个没得感情的杀手,
一个工具人
一个没得感情的编码工具
一个木有心的人
另外,我真的想吃烧烤,
还有,请给我一个女同桌
`
let alen = aa.length
let timer = null
function type(){
if(index === alen ){
clearInterval(timer)
return
}
let currentWord = aa.substring(0,index )
console.log(currentWord,`currentWord`)
document.getElementById("language_two").innerText = currentWord + aa[index]
index++
console.log('++++')
}
timer = setInterval(type, 100);
</script>
</body>
</html>
标签:原生,index,aa,currentWord,timer,js,let,弹字
From: https://www.cnblogs.com/hjk1124/p/18142930