1、模拟数据
const newList = new Array(10000000).fill(1).map((item, index) => {
return {
time: (index + 1) * 1000,
content: `这是第${index + 1}s发送的消息`
}
})
//time发生时间,content发生内容
2、发送的消息列表
const sendList = [];
function getMessage(time) {
let j = 0; // 循环次数
for(let i = 0, len = newList.length; i < len; i++) {
const item = newList[i]; j++;
//如果time是1234、1214这种,就需要取一个浮动范围
if(item.time === time) {
sendList.push(newList[i]) newList.splice(i, 1) i--;
} else if(sendList.length > 0) {
break;
}
}
console.log('播放进度', time)
console.log('循环的次数', j);
console.log('接收的消息的长度', sendList.length, sendList);
console.log('原始消息的长度', newList.length);
}
3、设置定时器
//1s触发一次
let time = 0;
setInterval(() => {
time += 1000;
getMessage(time);
}, 1000)
上面是“前端如何利用javascript实现弹幕数据循环”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2444.html
workflows工作流
梦幻中的一只猫咪ComfyUI工作流
一辆停在混凝土墙前运动型SUV捷豹概念车
一个十几岁的美国女孩穿着黄色连帽衫在黑暗和空虚的背景下闲逛
一只在森林里漫步的麋鹿ComfyUI工作流
一朵染血的白玫瑰ComfyUI工作流
一只沮丧的卡通小丑鱼ComfyUI工作流
乡村枯树黄花comfyui工作流
一只可爱的雪豹在雪地里散步ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

利用canvas画几个好玩的星云物种
会议人员60s签到倒计时插件
用ascii字符画图像
制作一个好玩的倒计时
css3动画loading效果
3d文字360度旋转
js实现下雪特效
黑客入侵效果代码














