【发布时间】:2020-02-12 16:12:10
【问题描述】:
请帮我解决倒计时
我现在得到的错误如下: 声明后缺少或未立即执行函数实现。
这是来自 app.component.html
<div app-landing>
</div>
这是html代码
<div class="container">
<!-- LEFT SIDE -->
<div class="split left" id="upComing">
<h1 id="uce">THE UPCOMING EVENT</h1>
<table id="tableTimer">
<tr id="timerValue">
<td id="days"></td>
<td id="hrs"></td>
<td id="mins"></td>
<td id="secs"></td>
</tr>
<tr id="timerSub">
<td>Days</td>
<td>Hours</td>
<td>Minutes</td>
<td>Seconds</td>
</tr>
</table>
</div>
<!-- RIGHT SIDE -->
<div class="split right" id="nextFive">
<h1 id="nfe">THE NEXT FIVE EVENTS</h1>
<table>
</table>
</div>
</div>
<div class="footer" id="footer"></div>
这是 ts 文件。我对 Angular 和 TS 完全陌生,帮我解决问题 想在桌子旁边显示倒数计时器。而且做不到。
enter code hereimport { Component, OnInit } from '@angular/core';
@Component({
selector: '[app-landing]',
templateUrl: './landing.component.html',
styleUrls: ['./landing.component.css']
})
export class LandingComponent implements OnInit {
constructor() { }
ngOnInit() {
}
countDown() {
var today, eventDay, currentTime, eventTime, remainTime, sec, min, hr, days;
today = new Date();
eventDay = new Date();
currentTime = today.getTime();
eventTime = eventDay.getTime();
remainTime = eventTime - currentTime;
sec = Math.floor(remainTime / 1000);
min = Math.floor(sec / 60);
hr = Math.floor(min / 60);
days = Math.floor(hr / 24);
hr %= 24;
min %= 60;
sec %= 60;
hr = (hr < 10) ? '0' + hr : hr;
min = (min < 10) ? '0' + min : min;
sec = (sec < 10) ? '0' + sec : sec;
document.getElementById('days').innerText = days;
document.getElementById('days').textContent = days + '' + ':';
document.getElementById('hrs').textContent = hr + '' + ':';
document.getElementById('mins').textContent = min + '' + ':';
document.getElementById('secs').textContent = sec;
setInterval(this.countDown, 1000);
}
countDown();
【问题讨论】:
标签: html css angular typescript web