当前位置: 首页 > news >正文

网站上传 404网络教学网站建设

网站上传 404,网络教学网站建设,一般通过什么来进行知识点挖掘,做缓网站效果 实现方式 计时器#xff1a;setTimeout或setInterval来计时。setInterval和 setTimeout 在某些情况下可能会出现计时不准确的情况。这通常是由于JavaScript的事件循环机制和其他代码执行所需的时间造成的。 问询#xff1a;通过getCurrentLight将每个状态的持续时间设置…效果 实现方式 计时器setTimeout或setInterval来计时。setInterval和 setTimeout 在某些情况下可能会出现计时不准确的情况。这通常是由于JavaScript的事件循环机制和其他代码执行所需的时间造成的。 问询通过getCurrentLight将每个状态的持续时间设置为精确的值并使用requestAnimationFrame来递归调用getCurrentLight函数我们可以更准确地控制交通灯的状态。 源码 index.html !DOCTYPE html htmlheadtitle交通灯/titlelink typetext/css relstyleSheet href./index.css //headbodydiv classtraffic-lightdiv classtraffic-containerdiv classlight green/divdiv classlight yellow/divdiv classlight red/div/divdiv classtime90/div/divscript typemoduleimport {TrafficLight} from ./TrafficLight.js;const time document.querySelector(.time);const trafficDom document.querySelector(.traffic-light);const light new TrafficLight({red:3,yellow:2,green:5,initial:red,});function raf(){requestAnimationFrame((){raf();const current light.getCurrentLight();time.textContent current.remain;trafficDom.className traffic-light ${current.color};console.log(current.color,current.remain);})}raf();/script/body /htmlindex.css * {margin: 0;padding: 0;box-sizing: border-box; }body{width: 100vw;height: 100vh;margin: 0;/* backgroud: #191c29 */background: #fff; }.traffic-light{width: 200px;margin: 10px auto;-webkit-box-flex: inherit;text-align: center; }.light{width: 20px;height: 20px;border-radius: 10px;display:inline-block;background-color: gray;margin: 10px auto; }.red .red{background-color: red; }.green .green{background-color: green; } .yellow .yellow{background-color: yellow; }.time{font-family: DS-Digital;font-size: 40px; }TrafficLight.js export class TrafficLight {constructor(options) {const {red 60,green 60,yellow 3,initial green,} options || {};this._colors {red:{seconds: red,next:yellow,},green:{seconds: green,next:yellow,},yellow:{seconds : yellow,},};this._switch(initial);}_switch(color){this._currentColor color;this._seconds this._colors[color].seconds;this._time Date.now();}_next(){if(this._currentColor red){this._colors.yellow.next green;} else if(this._currentColor green){this._colors.yellow.next red;} else{}this._switch(this._colors[this._currentColor].next); }getCurrentLight(){const remain Math.ceil(this._seconds -(Date.now() - this._time)/1000);if(remain0){this._next();return this.getCurrentLight();}return {color: this._currentColor,remain,};}}字体 DS-Digital 下载字体 DS-Digital 注意下载安装字体后需要重启浏览器才生效
http://www.sadfv.cn/news/249580/

相关文章:

  • 自己制作一个网站只要有足够的粉丝
  • 东莞seo网站优化运营广州百度seo 网站推广
  • pycharm网站开发实例wordpress 模板开发
  • 网站三大标签优化什么是网络营销什么是传统营销
  • 福州网站建设技术支持东莞网站建设策划
  • 免费网站建设制作h5网站开发框架
  • 怎样做才能让网站帮忙送东西公司网站包括哪些内容
  • 湖北建设信息网站 联系方式怎么做好seo推广
  • 企业网站的作用和目的网站开发期末作品代码和数据库运行好大全
  • 海淀做网站公司廊坊网站建设制作
  • win7家用电脑做网站服务器网站怎么建设原始站点
  • 空中客车网站建设需求做网站都需要什么资料
  • 河北涿州建设局网站特效素材免费下载网站
  • 上海创意网站建设编程平台
  • 给人做ppt的网站吗wordpress主题ux themes
  • 90设计网站怎么绑定手机号外贸网站建设哪里好
  • PHP搭建IDC网站行业网站渠道选择和内容运营
  • 公司搭建网站网络运维工程师的月薪有多少
  • 北京网站开发品牌摄影基地设计
  • 东营seo网站推广百度ocpc怎么优化
  • 怎么用服务器lp做网站做网站公司 上海
  • 电商购物网站开发网站维护运营优化公司
  • 电子商务网站设计物流方案linux系统服务器怎么做网站
  • 泸州网站开发模板网站建设哪家专业
  • 网站建设背景论文wordpress中用户注册
  • 网站建设的需求要素网站建设的公司工作室
  • 安徽网站建设制作网站目录编辑审核的注意事项
  • wordpress微信群机器人嘉兴优化网站公司哪家好
  • wordpress视屏播放器seo和sem的区别与联系
  • 做网站广告wordpress 文章新窗口