vue項目時間倒計時

一、年月日,時分秒

mounted() {
    this.getTime();
    this.getMonthData();
    setInterval(() => {
      this.getTime();
    }, 60000);
},
methods: {
    getTime() {
      // this.roadMap();
      var a = ["日", "一", "二", "三", "四", "五", "六"];
      var weeker = new Date().getDay();
      this.week = "星期" + a[weeker];

      var time = new Date();
      const y = time.getFullYear();
      const m = (time.getMonth() + 1 + "").padStart(2, "0");
      const d = (time.getDate() + "").padStart(2, "0");
      const hh = (time.getHours() + "").padStart(2, "0");
      const mm = (time.getMinutes() + "").padStart(2, "0");
      const ss = (time.getSeconds() + "").padStart(2, "0");
      this.getData = `${y}-${m}-$u0z1t8os`;


      this.getMinutes = `${hh}:${mm}:${ss}`;
    },
}

二、倒計時天

data(){

return{
      starttime: "2020 / 05 / 01",
      // 倒計時
      date: "",

      // 完工時間
      endtime: "2020 / 08 / 31",
}},
methods: {
    countDown() {
      // 開工時間
      var startDate = Date.parse(this.getTimeimg);
      // 完工時間
      var endDate = Date.parse(this.endtime);
      var days = (endDate - startDate) / (1 * 24 * 60 * 60 * 1000);
      // alert(days);
      // return days;
      this.date = days;
      // console.log(this.date);
    }
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容