vue 專案頁面出現多個時間 倒計時的
阿新 • • 發佈:2019-01-06
setTimeCount() { setInterval(() => { for (let j = 0; j < this.products2.length; j++) { const now = Math.round(new Date().getTime()); let tmpProducts = []; tmpProducts = this.products2; if (tmpProducts[j].started_at !== null) { tmpProducts[j].started_at = tmpProducts[j].started_at.replace(/\-/g, '/'); this.$set(this.products2[j], 'overtime', Date.parse(this.products2[j].started_at) - now); this.$set(this.products2[j], 'overD', Math.floor(Math.floor((Date.parse(tmpProducts[j].started_at) - now) / 1000 / 60 / 60 / 24))); this.$set(this.products2[j], 'overH', Math.floor((Date.parse(tmpProducts[j].started_at) - now) / 1000 / 60 / 60 % 24)); this.$set(this.products2[j], 'overM', Math.floor((Date.parse(tmpProducts[j].started_at) - now) / 1000 / 60 % 60)); this.$set(this.products2[j], 'overS', Math.floor((Date.parse(tmpProducts[j].started_at) - now) / 1000 % 60)); } } }, 1000); }