js,ts,vue循环生成延迟循环, 电脑版发表于:2025/6/4 17:23 直接使用setInterval会一直循环不会结束除非手动去结束,可以循环生成n次setTimeout,然后时间的循环每次递增就可以了 ``` const thinkingContent = ref('') const answerContent = ref('') onMounted(() => { let timeout = 0 for (let index = 0; index < 10; index++) { setTimeout(() => { thinkingContent.value += ',立法听证会护航未成年人网络权益,' }, timeout) timeout += 1200 } for (let index = 0; index < 10; index++) { setTimeout(() => { answerContent.value += ',我是内容我是内容我是内容我是内容我是内容我是内容,' }, timeout) timeout += 1200 } // setInterval(() => { // // thinkingContent.value += ',立法听证会护航未成年人网络权益,' // // answerContent.value += ',立法听证会护航未成年人网络权益,' // }, 1600) }) ```