使用setTimeout 表现出setInterval的效果

内容分享2小时前发布
0 0 0

 getDateTime() {

      this.dataTime.dateYear = formatTime(new Date(), “yyyy-MM-dd”);

      this.dataTime.dateWeek = this.dataTime.weekday[new Date().getDay()];

      this.dataTime.dateDay = formatTime(new Date(), “HH: mm: ss”);

      setTimeout(() => {

        this.getDateTime();    //在 函数里面写  setTimeout  调用函数本身 就会实现setInterval的效果

      }, 1000);

    }

© 版权声明

相关文章

暂无评论

none
暂无评论...